my program keeps crashing and I cant seem to see why, Well I do get another error now.<br><br>Unhandled Exception: System.TypeLoadException: Could not load type 'Odio.MatematiCa' from assembly 'alpineCalc, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. at Calculator.Main(String[] args)<br><br>Also I dont mean to be a pain here or anything, I'm just another newbie tring to learn.anyways.. here are my scripts.<br><br><br>calculator.cs<br><br>using System;using System.Text.RegularExpressions;using cono = Odio.MatematiCa;public class Calculator{ public static void Main( string[] args ) { //string retVal; Console.WriteLine( "\t\"\"Alpine Health Technology\"\"" ); if( args.Length < 3 ) { Console.WriteLine( "\n\n\t<Usage: Calculater.exe num1 + num2>" ); return; }else{ if( Regex.IsMatch( args[0], @"\d" ) == false || Regex.IsMatch( args[2], @"\d" ) == false ) { Console.WriteLine( "\n\n\tPlease No Characters!!!!" ); return; //Lets add a return function here so the program dont crash on me. }else if( Regex.IsMatch( args[1], @"-|\*|\+" ) == false ){ Console.WriteLine( "\n\n\tGeez, Go back to school" ); return; //Really dont need it here.. but its better being safe then sorry! }else{ long num1 = long.Parse( args[0] ); long num2 = long.Parse( args[2] ); string str = args[1]; cono.Puneta( num1, str, num2 ); Console.ReadLine( ); } } }}<br><br><br>namespace.cs<br><Br>using System;namespace Odio{ public class MatematiCa { public static void Puneta( long x, string y, long z ) { string result; switch( y ) { case "+": result = Convert.ToString( x+=z ); break; case "-": result = Convert.ToString( x-=z ); break; case "*": result = Convert.ToString( x*=z ); break; case "/": result = Convert.ToString( x/=z ); break; default: result = "Nothing to calculate"; break; } Console.WriteLine( "\n\nAnswer: {0}{1}{2}={3}", x, y, z, result ); } }}<br><br><br>Again, I been learning C# for only a few days now.. so please forgive me for my lack of knowledge.
--------------- edit ----------------
hmm that check box ( code sample ) sorta messed the post up.. but please view it here..
http://pastebin.ca/210252

Program Crashes. :(
Superchick
GOsborn
The problem is that the CLR can't load the type Odio.MatematiCa from the assembly alpineCalc. I noticed the version # is 0 which is an indication that the assembly may be bad. Verify that the assembly that you are trying to load is the correct version and that it contains the type you think it does. Since it compiled it is safe to assume that the version you compiled against is valid. Try copying it to your programs output directory and see if it works. Also note that if the assembly is stored in the GAC then it'll load it from there first.
Michael Taylor - 10/19/06
fddsfsdf
http://pastebin.ca/210252
Corres
KitWest
Can you specify the layout of your program Is the Calculator class and the MatematiCa class in the same project or separate projects When you compile the program do you get any compilation errors
Michael Taylor - 10/19/06
leclerc9
dillysdad
Ok. The source and compilation looks fine. Do you always get a runtime error with the TypeLoadException or just periodically Do you get the crash as soon as the app starts or only when it hits the line where it references your class in the other assembly
Michael Taylor - 10/19/06
bslim
The problem lies in your build command. You give both your library and your EXE the same name. Therefore when the compiler runs your class library is called AlpineCalc (the extension will get dropped for the assembly name). Furthermore your executable is also called AlpineCalc. At runtime the loader would normally try to load the assembly with the name AlpineCalc but since that is the name of the execute it doesn't have to. However when it tries to load the type it'll fail since the EXE does not define the type.
You need to give your library a different name from your executable. You can't simply rename the binary as the assembly name is a compile-time determination. Once you rename the library it should work.
Michael Taylor - 10/19/06
Burt Harris
Compiling namespace file to .dll
C:\c-sharp>csc.lnk /target:library /out:c:\c-sharp\Calculator\alpineCalc.dll c:\
c-sharp\Calculator\calcspaces.cs
Compiling calculator.cs to exe with reference
C:\c-sharp>csc.lnk /out:c:\c-sharp\Calculator\alpineCalc.exe /reference:c:\c-sha
rp\Calculator\alpineCalc.dll c:\c-sharp\Calculator\calculator.cs