I'm new to programming in C#. Problem I'm getting is when compiling a program it is giving me a reference error. I'm not completely clear on how to fix it.
Error 1 The type 'System.IO.Ports.SerialPort' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll' and 'c:\Documents and Settings\Mobile1\Desktop\Snap_Library\Master\SerialPort.dll' C:\Documents and Settings\Mobile1\Desktop\Snap_Library\Master\Snap.cs 11 11 Master
I know about the whole removing the reference of the "SerialPort.dll" but it has required references within it. And I can't remove the system.dll reference either. Can anybody give me a clue on what to do?
You going to have to use one or the other. Judging from the message, a class with the name SerialPort exists in both System.IO.Ports namespaces in both files. You can only use one SerialPort class definition however. Seems like poor insight on whoever wrote the SerialPort.dll file or something... Or if the namespace is indeed different in the SerialPort.dll file, use the fully qualified name to the SerialPort class.
R.I.P. 3.5" Floppy Drives
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
I believe the program was written in 2003, I'm trying to modify a pre-existing program. I probably should have stated that, sorry. From my understanding, the system.dll doesn't have a specific reference the serialport.dll has, so even if I do remove the serialport.dll, I run into another error later on in the code.
system.dll should contain the namespace System.IO.Ports with the class SerialPort in that namespace. If you can remove the reference to the SerialPort.dll file it should fix the problem since your only referencing two libraries. I dont think Im understanding the problem, here is how I understand it:
You are referencing two libraries, system.dll and SerialPort.dll
Both of the files contain a namespace System.IO.Ports
Both of the files contain a class named SerialPort in that namespace
The compiler doesnt know which SerialPort class to use because the namespaces and class names are identical
Am I sort of correct? lol
R.I.P. 3.5" Floppy Drives
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
I think I'm confused.... I've attached the code to the message. Can one of you take a look at it and see? Thanks for the help either way though. Much appreciated.
So you are saying that both dll's declare the System.IO.Ports namespace? I find that very hard to believe. If your third party dll does that then it was written by a group of morons, seriously.
So you are saying that both dll's declare the System.IO.Ports namespace? I find that very hard to believe. If your third party dll does that then it was written by a group of morons, seriously.
Thats what I said, but if it were written in the .NET 1.1 days its quite possible. Sorry to say but if this is the case you probably wont be able to use that library. Youll either have to find another 3rd party library or roll your own. I always opt for rolling my own, I dont trust alot of 3rd party libraries for this very reason.
Last edited by RaleTheBlade; August 1st, 2009 at 09:28 AM.
R.I.P. 3.5" Floppy Drives
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.