Monday, July 27, 2009

Exception when I run a program developed with C# .net 2.0?

I used visual studio 2005 to developed an application. it was working well. recenty i used "Computerinfo" class of "Microsoft.VisualBasic.Devices" namespace. for which I had to add a visual basic dll as reference. But my problem is when I run the program from Visual Studio 2005 IDE It works fine. but after publishing It throws an exception with 'detail', 'quit' and 'continue' button.





************** Exception Text **************


System.Management.ManagementException: Provider load failure


at System.Management.ManagementException.Th... errorCode)


at System.Management.ManagementObjectCollec...


at System.Management.ManagementObjectCollec...


at Microsoft.VisualBasic.Devices.ComputerIn...


at Microsoft.VisualBasic.Devices.ComputerIn...


at MountUp.MainUI.MainUI_Load(Object sender, EventArgs e)


at System.Windows.Forms.Form.OnLoad(.....

Exception when I run a program developed with C# .net 2.0?
I recall reading somewhere that not all of the "My" objects available to VB function properly in C#. Since most of the objects provided through the "My" keyword are available to C# through other means, it's probably better in the long run to spend a little more time to write the code for that directly. You didn't say exactly what property you were trying to access when the exception occurred, but from what I can see that's available through the ComputerInfo class you'll probably have to resort to pinvoke to get most of that info.

garden centre

No comments:

Post a Comment