By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,777 Members | 1,499 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,777 IT Pros & Developers. It's quick & easy.

Big in Framework 2.0 with wmi?

P: n/a
Hello,

this is my code with vs20005:

ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_Printer");

foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_Printer instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("Name: {0}", queryObj["Name"]);
}

I use wmi for found all printer name.
This is my exception:
Unable to find an entry point named 'GetCurrentApartmentType' in DLL
'wminet_utils.dll'.

The code work well in vs2003 but in vs2005 i have the exception.
I think there is a problem with the framework 2.0.

If you have any idea or info!

Best regards,

Wavemill

May 12 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
wavemill wrote:
Hello,

this is my code with vs20005:

ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_Printer");

foreach (ManagementObject queryObj in searcher.Get())
{


Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_Printer instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("Name: {0}", queryObj["Name"]); }

I use wmi for found all printer name.
This is my exception:
Unable to find an entry point named 'GetCurrentApartmentType' in DLL
'wminet_utils.dll'.

The code work well in vs2003 but in vs2005 i have the exception.
I think there is a problem with the framework 2.0.

If you have any idea or info!


Is that the complete code? It works fine here under both vs2003 and vs2005.
Are you referencing the correct version of System.Management.dll?
--
Tom Porterfield

May 12 '06 #2

P: n/a

"wavemill" <wa******@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
Hello,

this is my code with vs20005:

ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_Printer");

foreach (ManagementObject queryObj in searcher.Get())
{

Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_Printer instance");

Console.WriteLine("-----------------------------------");
Console.WriteLine("Name: {0}", queryObj["Name"]);
}

I use wmi for found all printer name.
This is my exception:
Unable to find an entry point named 'GetCurrentApartmentType' in DLL
'wminet_utils.dll'.

The code work well in vs2003 but in vs2005 i have the exception.
I think there is a problem with the framework 2.0.

That code works fine for me in VS2005. By the way have you seen the WMI
branch on the server explorer in VS2005. You can drag the printer object
onto a component and it will create the typed object wrappers for you. Then
you can use something like

foreach (Printer ptr in Printer.GetInstances())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_Printer instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("Name: {0}", ptr.Name);
}

David
May 12 '06 #3

P: n/a
Tom Porterfield wrote:

Is that the complete code? It works fine here under both vs2003 and
vs2005. Are you referencing the correct version of System.Management.dll?


I know, bad form replying to myself.

You might try the following instead as it should run faster than WMI calls:

foreach (string printer in
System.Drawing.Printing.PrinterSettings.InstalledP rinters)
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("Printer instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("Name: {0}", printer);
}

--
Tom Porterfield

May 12 '06 #4

P: n/a
Hello!

Thank you for your answer!

I want use wmi not just for printer name...

I have try to open the WMI
branch on the server explorer in VS2005 but i have the same exception:
Reason: Unable to find an entry point named 'GetCurrentApartmentType' in DLL
'wminet_utils.dll'.

I don't know why!

If you have an idea!

Best regards,

Wavemill
May 12 '06 #5

P: n/a

"wavemill" <wa******@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
| Hello,
|
| this is my code with vs20005:
|
| ManagementObjectSearcher searcher =
| new ManagementObjectSearcher("root\\CIMV2",
| "SELECT * FROM Win32_Printer");
|
| foreach (ManagementObject queryObj in searcher.Get())
| {
|
Console.WriteLine("-----------------------------------");
| Console.WriteLine("Win32_Printer instance");
|
Console.WriteLine("-----------------------------------");
| Console.WriteLine("Name: {0}", queryObj["Name"]);
| }
|
| I use wmi for found all printer name.
| This is my exception:
| Unable to find an entry point named 'GetCurrentApartmentType' in DLL
| 'wminet_utils.dll'.
|
| The code work well in vs2003 but in vs2005 i have the exception.
| I think there is a problem with the framework 2.0.
|
| If you have any idea or info!
|
| Best regards,
|
| Wavemill
|

Looks like your .NET install is broken, could you verify the version of
'wminet_utils.dll', it should be 2.0.50727.42 with size on disk 28.672
bytes? Another option is to run depends.exe or dumpbin.exe to verify whether
'GetCurrentApartmentType' is exported.

Willy.

May 12 '06 #6

P: n/a
Hello!

Thank you for your answer!

The siez and the version of wminet_utils.dll are ok.
But i have reinstall the dotnet framework and now it's ok.

Tanks for your help,

Best regards,

Wavemill
May 12 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.