4

I need to compile two files: server.cs and client.cs which use the file server.cs; and so obtain two .exe file server.exe and client.exe in the Desktop.
Since, I am doing the compilation via code, I am calling the process from the Desktop directory: c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe.

After, I have read this topic: How to use references when compiling c# code via command line
I understood that for solve my problem I should use the reference option.

This is what I am doing:

c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe /out:server.exe server.cs

In order to create the server.exe file, and it works.

c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:library server.cs

In order to create the server.dll file, and it works.

c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /lib:C:\Users\MyName\Desktop\ /r:server.dll /t:exe /out:client.exe client.cs

In order to create the client.exe file, but I got the following error:

"The type or namespace name 'server' could not be found (are you missing a using directive or an assembly reference?);"

Community
  • 1
  • 1
Draxent
  • 500
  • 1
  • 6
  • 14
  • Use the /lib or /reference compiler options: http://msdn.microsoft.com/en-us/library/s5bac5fx.aspx / http://msdn.microsoft.com/en-us/library/yabyz3h4.aspx – John Jan 05 '15 at 21:36
  • You need to put it somewhere that the fusion loader can find it. Turn on fusion logging to see where csc is looking for it. (Assuming fusion is trying to load this--the error message sounds fusion-y. If CSC error message, one of the above comments should do) –  Jan 05 '15 at 21:36

1 Answers1

-1

Why don't you build the server.cs and client.cs together while building client.exe. Looks more natural (albeit less efficient) to me.
This way you don't build server.cs as an exe and as a dll, and hopefully solving your build issue

c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe /out:server.exe server.cs

c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe /out:client.exe client.cs server.cs

Vikhram
  • 4,294
  • 1
  • 20
  • 32