Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all 8156 articles
Browse latest View live

Xsd Schema with include attribute as Embedded Resource

$
0
0

I'm setting my schemas files as Embedded Resource, here the code I tried:

 public MainWindow()
        {
            InitializeComponent();
            var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WpfApplication1.TransmissionHeader_v1.00.xsd");
            var xml = File.OpenRead("Header.xml");
            ReadSchema(stream, xml);
        }

        private void ReadSchema(Stream XsdFile, Stream XmlFile)
        {
            var xmlSchema = XmlSchema.Read(XsdFile, null);
            XsdFile.Position = 0;

            var xmlDocument = new XmlDocument();
            xmlDocument.Load(XmlFile);
            xmlDocument.Schemas.Add(xmlSchema);
            xmlDocument.Validate(ValidationEventHandler);

        }

        private void ValidationEventHandler(object sender, ValidationEventArgs e)
        {
            if (e.Severity == XmlSeverityType.Error)
            {
                
            }
        }

The schemas:

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"><xsd:include schemaLocation="TransmissionData_v2.00.xsd"/><xsd:element name="Transmission" type="TransmissionHeaderXml"/><xsd:complexType name="TransmissionHeaderXml"><xsd:sequence><xsd:element name="Id" nillable="true" type="xsd:int"/><xsd:element name="Name" nillable="false" type="xsd:string"/><xsd:element name="Date" nillable="false" type="xsd:dateTime"/><xsd:element name="LastTransmitedOn" nillable="true" type="xsd:dateTime"/><xsd:element name="Teste" nillable="true" type="Guid"/></xsd:sequence><xsd:attribute name="IsOffline" type="xsd:boolean" use="required"/><xsd:attribute name="Status" type="TransmissionStatusXml" use="required"/></xsd:complexType><xsd:simpleType name="TransmissionStatusXml"><xsd:restriction base="xsd:string"><xsd:enumeration value="OnDemand"/><xsd:enumeration value="StandBy"/><xsd:enumeration value="Live"/><xsd:enumeration value="Suspended"/><xsd:enumeration value="Finished"/></xsd:restriction></xsd:simpleType></xsd:schema>

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"><xsd:simpleType name="Guid"><xsd:restriction base="xsd:string"><xsd:pattern value="([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})|(\{[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\})"/></xsd:restriction></xsd:simpleType></xsd:schema>
As you can see, I'm including one Schema in another, but how can I get both as embedded resource?

And here's the following error:

Type 'Guid' is not declared.


Take a look at WPF FlashMessage
About.me


Type initializer for threw an exception

$
0
0

I want to run my executable file (after installing the setup of my ERP) , the login screen appears and after taking the credentials of the user, hitting the OK button generates the following error :

Type initializer <module name> threw an exception...

When I debug  my project it works absolutely fine but after deploying to a client machine this error generates

Some details:

1) Project developed on .net framework 3.5 (using VB.net)

2) Gives error on 64-Bit operating systems.

3) Works fine if visual studio 2008 is installed on the client machine.

Any help ?

Regards,

Avaneesh.


write in current position

$
0
0

Hi,

I am developing a virtual keyboard form with all keys on it and a TextBox to write the result

I am using text_position to store the current position in order to write on it

for example if the user wrote Jon and he wanted to add h so he will click after o then click the button O

here is the code:

private void txtKeyboard_Leave(object sender, EventArgs e)
{
    text_position = txtKeyboard.SelectionStart;
}

private void btnKeyH_Click(object sender, EventArgs e)
{
    txtKeyboard.Text = txtKeyboard.Text.Insert(text_position, ((DevExpress.XtraEditors.SimpleButton)sender).Text);
}

now the problem... I can write to the same position with out issue but after clicking btnKeyH  the cursor will remain in the same position although it should move after the newly written h letter.

How can I solve this?

Delegated Event

$
0
0

Hi

I have 2 classes. TestPort class tests CommPort one.

My problem is with the definition & usage of the Read Event

Here is TestPort that should trap CommPort's Read event

using System;
using System.IO.Ports;
using CommPortNS;

public class TestPort
{
   public static int Main(string[] args)
   {
       CommPort Port;
       Port=new CommPort();
    
       Port.MyEvent += MyHandler;

       SerialPort sp;
       sp=Port.InitPort("COM3",9600);

       // Available via CommPortIF
       // Port.InitPort
       // Port.ListPortSetup
       // Port.Write
       // Port.ReceivedData
       // Go

       Port.ListPortSetup();

       Port.Go();
      
       Port.Write("ATZ");
       Port.Write("ATE0");
       Port.Write("ATDT1234567");
       Port.Write("ATH1");
       //Port.Write("quit");
       Console.WriteLine("Aborting ... press Shift F5  " );
       Console.ReadKey();
       return 0;
   }


   public static void MyHandler(string s)
   {
       Console.WriteLine("Event occured");
   }

  
    /* in VBA I expect to trap the event 
     * 
     * Private oCOM As New CommPort
     * Private WithEvents COMevent As CommPort
     * Private Sub COMevent_MyEvent(Data As string )
     *  Debug.Print "com event"
     * End Sub
     */

}

CommPort class should trigger Read Event

   [ClassInterface(ClassInterfaceType.AutoDual)]
    public class CommPort : PortParamIf
    {

        public static string RxData { get; private set; }

        public delegate void MyDelegate(string s);
        public event MyDelegate MyEvent;
....

      public static void Read()
        {
            while (_continue)
            {
                try
                {
                    RxData = _serialPort.ReadLine();
                    CommPort Obj=new CommPort();   // OK ???
                    Obj.On_MyEvent();
                }
                catch (TimeoutException) { }
            }
        }
.....

       public void On_MyEvent()
        {
            // MyEvent is always null   <<<<<<<<<<<<<

            if (MyEvent != null)
            {
                 MyEvent(RxData); 
            }
        }

Any educational support would be appreciated

Thanks

How to get information from the idle state of wlan in C# windows 7

$
0
0

In my project I need to detect the idle state of wlan in windows 7, but failed because the class I use System.Net.NetworkInformation Namespace. NET.

The class specifies the operational state of the network interface: "Dormant, Down, LowerLayerDown, notPresent, Testing, Unknown, Up"

Link: http://msdn.microsoft.com/en-us/library/system.net.networkinformation.operationalstatus.aspx

None of these states seem to correspond to the idle state of wlan.

Researched how information of energy states but only found the. Net compact framework in: enum _CEDEVICE_POWER_STATE. Link: "msdn.microsoft.com/pt-br/library/aa932261.aspx

I tried to do a WMI query on "Win32_NetworkAdapter" link: "http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx" field "uint16 Availability" for "Meaning Value = 14 = Power Save - Low Power Mode" or "Value Meaning = 15 = Power Save - Standby" but the query only returns "value = 3 = Meaning Running or Full Power" even the network adapter off.

how to append items to existing listview

$
0
0

Hi

i have listview with headrs in place (8 columns) the first  four of them get populated at the start of programm and do not need to be changed; and the remaining  are to be populated  periodically  by 10  background threads ( equal to number of rows in listview);

void InitListCtr()
{
    listView1.Columns.Add("DB Server Name", 80, HorizontalAlignment.Left);
    listView1.Columns.Add("Locale No ", 80, HorizontalAlignment.Left);
    listView1.Columns.Add("Db No", 65, HorizontalAlignment.Left);
    listView1.Columns.Add("Locale ", 85, HorizontalAlignment.Left);
    listView1.Columns.Add("Status ", 65, HorizontalAlignment.Left);
    listView1.Columns.Add("Service  ", 65, HorizontalAlignment.Left);
    listView1.Columns.Add("Records", 65, HorizontalAlignment.Left);
    listView1.Columns.Add("Next Run  ", 95, HorizontalAlignment.Left);
}

the first four columns are added like this

  for (int i = 0; i < 10; i++)
{
                tm = new string[5];
                tm[0] = CDBProcessHandlerEx.SwitchObjects[i].dbserver;
                tm[1] = CDBProcessHandlerEx.SwitchObjects[i].localNo.ToString();
                tm[2] = CDBProcessHandlerEx.SwitchObjects[i].dbNo.ToString();
                tm[3] = CDBProcessHandlerEx.SwitchObjects[i].localeName;
            itm = new ListViewItem(tm);
                listView1.Items.Add(itm);
  }   

my question is:

assuming localNo is unique 

assuming my threads return string[] object including localNo

how can I append  the rest of columns to the existing columns?

external event handler

$
0
0

Hi

I have a C# (VS2010) class written to be a COM Dll used by Outlook VBA

It supports serial port having ReadEvent which handler is external (will be implemented  in VBA)
coded :

[DllImport("Cmdll.dll")] public static extern void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e);

Port.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);

How do i eliminate the DllImpot ?  or is there other alternative ?

Would appreciate your advice

Thanks


Various Technologies in Speech Recognition

$
0
0

I would like to provide Speech recognition to my ASP.NET Web Application.

I am confused with the following five references and their documentations. I appreciate any deceleration or short explanation for each.

http://www.microsoft.com/en-us/download/details.aspx?id=24003

http://www.microsoft.com/en-us/download/details.aspx?id=10121

http://www.microsoft.com/en-us/download/details.aspx?id=10208

http://www.microsoft.com/en-us/download/details.aspx?id=35463

http://archive.msdn.microsoft.com/nesl

Beside those five, there is the (System.Speech) Namespace that is available as a .NET library in ASP.NET/Windows application, but not in Silverlight. Is it one of the above references?

Note1: Silverlight 5 provides the ability to use In-browser elevated trust application as described here. That's why I thought it is possible now to run the speech recognition on the client side instead of using web services.

Note2: I prefer to have the ability to dictate text, not only say pre-defined words.

Any further advices to achieve my goal will be appreciated.




Binary Validation File

$
0
0
Hi,

I would like to ask how can I implement a binary validation file which my C# application will check everytime on startup to make sure the application is activated on the valid machine?

How to Open Cash Drawer

$
0
0

Hi,

I want to ask if there is a standared Cash Drawer APIs for .NET which will open any type of cash drawers regardless of the brand?


about status check in sourcesafe

$
0
0
I develop my project but I have problem
my computer can not reboot. I format my computer
but status checkout before alive.
now I can not develop my job.

how I can make it ?

someone can help

Find error "Namespace or type specified in the Imports" when refer to another DLL

$
0
0

Dear all,

I'm developing on VB.NET .Net framework 4.0

And I have build a class library and call successfully from some test project

But when I create a Command Line Console Application and ref to that dll, I find the following error when I compile the console application

warning BC40056: Namespace or type specified in the Imports 'MyTestDll.MySession' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

And seem it cannot reference to the dll successfully

Do you know any possible cause of such error?

C# Argument Not Proper Exception

$
0
0

I have the following function in my COM dll class

[DispId(1610809401)]

intWriteBinValues(refstringSignal,refArrayvalues,refboolWithEv);

When I am using tthis function as

mt.WriteBinValues(StateSignal, vals, value);

where StateSignal is string

vals is not of array type it is of some class type variable which is giving run time exception when I am running the code. How can I solve this exception?

value is of bool type.

I/O Exception Serialport.datareceived VB.NET 4

$
0
0

I get an I/O exception when I run serialport.close() "The I/O operation has been aborted because of either a thread exit or an application request". The exception comes from the datareceived event. I don't want this exception, can anyone tell me how to get rid of it. I have tried Removehandler and sleep before calling close(), but nothing seems to help. In my datareceived procedure I have;

if SerialPort1.IsOpen then

Try

         readBuffer = SerialPort1.ReadLine()

         Me.BeginInvoke(New EventHandler(Addressof DoUpDate))

Catch Ex as Exception

          MsgBox(ex.message)

End Try

End If

I am sure that the exception comes from the ReadLine() statement when I try to close the serialport with serialport1.close. Thank you in advance for your help.

how to compare 2 .csv files in C#

$
0
0
 how to compare 2 .csv files in C#

adityadugyala


Powerbuilder and .net

$
0
0
Can we call a powerbuilder *.pbl file from a .net application?

Shivendra

ERROR EN VISUAL 2010

$
0
0
Tengo un proyecto realizado en VS2008, y estoy utilizando un control label de infragistics donde le asigno un gráfico a la propiedad image del appearance. He pasado el proyecto a VS2010 y esa misma propiedad me devuelve un error cunado asigno la imagen:
"Error al generar el código para la propiedad 'Image'. El error es: 'El nombre de ensamblado o el código base dado no es válido. (Excepción de HRESULT: 0x80131047)'"

Capture print job in legacy system

$
0
0

I have a legacy system (black box) that does various calculations and prints to a dot matrix printer.  Instead of printing to a printer, I would like to get rid of the dot matrix printer and connect the legacy system (black box) to another computer and capture the print job, parse the data and store it for later use (email it, reporting, etc).

Is there anyone that can point me in the right direction to accomplish this goal?  Here is the type of printer it currently connects to:
OKI Microline  320 Turbo
http://www.ebay.ca/ctg/OKI-MICROLINE-320-Turbo-Point-Sale-Dot-matrix-Printer-/48464406

Thank you!


MT

What is msvcr100d.dll?

$
0
0
What is msvcr100d.dll? What is its purpose?

C# deleate event - how do you say it in VBA ?

$
0
0

Hi

My Test class attach handler as CommPort.MyEvent += MyHandler;     (C#)

CommPort is the class being tested. It generates events.

How should i code the said statement  in VBA using AddressOf ?

CommPort class header

   [ClassInterface(ClassInterfaceType.AutoDual)]
    public class CommPort : PortParamIf
    {
        .....

        public delegate void MyDelegate(string s);
        public static event MyDelegate MyEvent;

        .....

       public static void OnMyEvent()
        {
            if (MyEvent != null && RxData.Length > 1 )
            {
                 MyEvent(RxData); 
            }
        }

Seems that MyEvent is not exposed to VBA, how do i rectify it ?

Thanks


Viewing all 8156 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>