• 0

C#


Question

okay...i'm programming in console applications using VS.net RC...now, i'd like to link and compile two files (one *.cs and the other *.dll) file together and get the program to work, but it just won't.

i have two files...and it runs perfectly if both of them are *.cs...but not if i rename one to *.dll (maybe i'm not supposed to rename)...

i know it can be done in the Framework SDK by typing commands on the command line...but don't know how to do it in VS.net...please help!

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

You have to create a seperate solution with a library as target.

Btw, renaming doesn't work.

In cmdline you can do

csc /t:library file.cs

which spits out the DLL. But as said, in VS.net you have to create a seperate project/solution/whatever-MS-calls it. Renaming doesn't work, you have to compile it :)

Link to comment
Share on other sites

  • 0

i tried that command line command, but it gave me an error that it doesn't recognize 'csc' as a command...

how do i do it by making a separate project and stuff??...because the way i had the two files...one called the other one using namespaces and stuff...

can ya have some sort of step-by-step thing shows how to do this?

Link to comment
Share on other sites

  • 0

Nevermind...figured it out...took a lot of brain cells...ended up with a couple more questions though...

Is there any way to call a file without actually having it copied to the project??

How can I call a class/method in a different project which is associated to the same solution??

Looking forward to some replies!...not views...replies!

Link to comment
Share on other sites

  • 0

LOL

First of all .CS is source code, which gets compiled into .DLL on build.

If you have a Solution with the two projects, means one for the EXE and one for the DLL, rightclick in the solution tree the root object (which should be the name what u gave the solution) and choose Properties. In Common Properties -> Project Dependency you can define the dependencies. Check the DLL project as dependency for the EXE project, and it will compile before the EXE on build. It will also copy the DLL into the EXE build folder if the EXE project needs the DLL.

--edit--

Screenshot

http://users.skynet.be/tomservo/blahvs.gif

Link to comment
Share on other sites

  • 0

i just tried your way, and it didn't seem to work...it gives me an error that namespace can not be found. the namespace was created in the library project. i even set the dependancies...but still doesn't seem to work...any ideas?

the only way it worked was when i created a new library project, then compiled the file, then selected the compiled *.dll file as a reference to my main program, which copied it to the debug folder of the main program.

Link to comment
Share on other sites

  • 0

another thing...why is it that the only input variable that seems to work is 'string'..??...i tried to input 5 as int...and it read in 53 instead...why is that??

and why can't i input two (well, more than 1) integer numbers??...it lets me enter the first one, but skips through the second one for some reason...only seems to work if i input as string.

BTW...using Microsoft Visual Studio.net Enterprise Developer Edition now :D w00t!!!

Link to comment
Share on other sites

  • 0

gee...last three posts by me...kinda sad...

another question in console applications....how do i use the random function (whatever C# has to offer in that area)...anything to randomize numbers/strings/characters...preferably in a specified range...

Link to comment
Share on other sites

  • 0

Use the Random class...

Initialise the class like this, with NO SEED:

<pre>

  Random myRand = new Random();

</pre>

or with the seed as the current tick count:

<pre>

  Random myRand = new Random((int)DateTime.Now.Ticks);

</pre>

To get values use:

<pre>

  nRandVal = myRand.Next();  //No limits

  nRandVal = myRand.Next(100);  //Max of 100

  nRandVal = myRand.Next(50, 100);	//Between 50 & 100

</pre>

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.