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

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

2006-08-01 10:53:14, Category: Programming & Design
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.ThrowWithExtendedInfo(ManagementStatus errorCode) at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext() at System.Management.ManagementObjectCollection.get_Count() at Microsoft.VisualBasic.Devices.ComputerInfo.get_OSManagementBaseObject() at Microsoft.VisualBasic.Devices.ComputerInfo.get_OSFullName() at MountUp.MainUI.MainUI_Load(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(.....

Answers

  1. Mills

    On 2006-08-01 13:42:25


    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.