المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : A problem with namespace?



C# Programming
10-20-2009, 05:10 AM
I'm trying to compile my project but its giving me this error:

1. The namespace 'PenDriveBackupProgram' already contains a definition for 'PenDriveBackup'

Prior to this error I was trying to get this class working in my project:
http://downloads.cfdan.com/csharp/us...lnumber.cs.txt

I was calling the class like so:
USBDriveSerialNumber.USBSerialNumber usb = new USBDriveSerialNumber.USBSerialNumber();
string serial = usb.getSerialNumberFromDriveLetter(path);
MessageBox.Show(serial);

But now there is an error in the class which is appearing at runtime?
The error is with this bit of code;
ManagementObjectSearcher searcher1 = new ManagementObjectSearcher("SELECT * FROM Win32_LogicalDiskToPartition");
foreach (ManagementObject dm in searcher1.Get())
And the error is:
Context 0x33c3ff0 is disconnected. No proxy will be used to service the request on the COM component. This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the application is completely done with the RuntimeCallableWrappers that represent COM components that live inside them.

I read some information at MSDN about the project needing full trust, so I went into the project settings -> security -> Enabled ClickOnce Security Settings -> Selected This is a full trust application.

Although I set the global settings to Full Trust the class has the modifer Partial so I figured this could be a problem (First project in C#)
So I removed the partial modifier with everything to do with the PenDriveBackup class which now results in the error you see above.

All help is appreciated greatly, cheers, George.