After upgrade to 2.0, Error CS1595 System.TimeSpan is defined inmultiple places

B

brentbackup

I know I'm some years behind, but I just have the go-ahead to start
developing on .Net 2.0. While the development process goes ahead, I'm
to maintain the .Net 1.1 stuff on the same machine.

I downloaded and installed the 2.0 framework. As I understand it, 1.1
and 2.0 are supposed to play nice with each other. However, now when I
go about compiling a class using CSC.exe, I get this error (among
others):

---------------------
warning CS1595: 'System.TimeSpan' is defined in multiple places; using
definition from c:\WINDOWS\Microsoft.NET\Framework
\v1.1.4322\mscorlib.dll
---------------------

Despite "only" being a warning, the compilation doesn't seem to take,
such that the DLL is not produced.

I've done an exhaustive search on the machine for multiple
mscorlib.dll files. There are four, in these locations:

1) c:\I386\netfx.cab
2) c:\windows\servicepackfiles\i386
3) c:\windows\Microsoft.Net\framework\v.1.1.4322
4) c:\windows\Microsoft.Net\framework\v.2.0.50717

If necessary, I will uninstall 2.0. That will probably fix it. Short
of that, however, is there any other solution?

Thanks for any pointers.

--Brent
 
M

Marc Gravell

Are you intentionally referencing both 1.1 and 2.0? What csc command
are you using? Call me lazy, but I do like using tools like VS, which
will sort out this type of issue for us...

Marc
 
B

Brent

Are you intentionally referencing both 1.1 and 2.0? What csc command
are you using? Call me lazy, but I do like using tools like VS, which
will sort out this type of issue for us...

Marc

Thanks for the heads up, Marc. My CSC command looks like this (sans
line feeds):

C:\[PathToCSC]\csc.exe
/t:library
/out:C:\[PathToBin]\bin\toolbox.dll
C:\[PathToCSFile]\toolbox.cs
/r:c:\windows\Microsoft.NET\Framework\v1.1.4322\System.Web.dll
/r:c:\windows\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll
/r:c:\windows\Microsoft.NET\Framework\v1.1.4322\System.Data.dll
/r:c:\windows\Microsoft.NET\Framework\v1.1.4322\system.dll
/r:c:\windows\Microsoft.NET\Framework\v1.1.4322\system.web.dll
/r:c:\windows\Microsoft.NET\Framework\v1.1.4322\system.xml.dll

Weird stuff...
 
B

Brent

And just checking: are you using the 1.1 version of csc, or the 2.0
one?

Marc

This is a good question. Actually, I'm using a csc.exe located in the
same folder as the .CS file. When I pointed to the CSC.exe file
located in c:\windows\Microsoft.NET\Framework\v1.1.4322\ , the
compiling works fine! Could it be that the absence of a csc.exe.config
in the local folder causes the csc to look all over the place for the
referenced namespaces, and come up with conflicts?

Whatever the case, I'm back on track.

Thanks, Marc.

--Brent
 
P

Pavel Minaev

This is a good question. Actually, I'm using a csc.exe located in the
same folder as the .CS file. When I pointed to the CSC.exe file
located in c:\windows\Microsoft.NET\Framework\v1.1.4322\ , the
compiling works fine! Could it be that the absence of a csc.exe.config
in the local folder causes the csc to look all over the place for the
referenced namespaces, and come up with conflicts?

Not really. It's just that csc always references some assemblies (in
particular, mscorlib) from the corresponding version of .NET
Framework, and then also those that you explicitly specify. In your
case, it would seem that this results in both mscorlib from 1.1 and
mscorlib from 2.0 being referenced, hence the clash.

.NET 1.1 and 2.0 do play nice with each other in a sense that they can
be installed side by side, and programs will run using whatever
version of .NET they were built with. But if you're compiling with csc
2.0, you should really be referencing 2.0 assemblies, not 1.1 ones.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top