Log in to reply
 

CS vs DLL Revisited



  • I remember posting about this when I first started scripting, and it was met by disbelief by some forum members, - that some .cs files need to be compiled as dlls in order to work. I new this was the case because I had one or two .cs files that wouldn't run unless compiled. One of the explanations might be missing external libraries - but nope, not the case I'm writing about today.

    Anyway today I wanted to share a .cs file which is short and sweet but can't get it to run. It works compiled in my LemonUI menu mod, it worked when i cut out that code and compiled it as its own dll, but it will not work as a .cs file. Which doesn't make sense or does it?

    Which assemblies/references am I using. Well in this case they couldn't be any simpler:

    using System.Windows.Forms;
    using GTA;
    using GTA.Math;
    using GTA.Native;

    There are no references to LemonUI or NativeUI or other libraries and I have all the necessary SHVDN files installed. So what gives? I can understand why it might not run on another GTA5 installation but why the hell not on my own when it runs compiled?

    I'm not looking for why my specific code won't run uncompiled, am I looking for more general reasons why a .cs file won't run.



  • What's the error in ScriptHookVDotNet.log?

    Did you write this using the v2 or v3 API. If the v3 API, you'll have to use the .3.cs extension instead of just .cs so SHVDN knows to load using the v3 API.



  • @Jitnaught Thanks for your answer.

    I had seen the extension change for the 3 API but had never used it since I always compile. Of course I remembered it wrong, so i had the extension as .3cs, which seems logical, rather than .3.cs. So that was the problem and the solution. Having said that, I've never seen an extension like that on any windows file format, why the extra dot?

    Once more thanks for solving a puzzle.



  • It's like that so the file is still recognized as a C# file (by Windows Explorer for example), but can be parsed by SHVDN easily.



  • @Jitnaught Since Windows doesn't have a native application for the .cs extension AFAIK, the process is still manual, right? When I double click a .cs file it opens notepad++, not Visual Studio, because I created the file association which didn't exist before installing notepad++ or VS.

    I understand the principle but naming it .3cs would have just meant creating a new file association. But that's just me. Thanks very much for the explanation but more importantly for the solution (no pun intended).



  • When you install Visual Studio I believe it automatically associates with .cs files. It would not with .3cs files.



  • @Jitnaught Yeah it likely did. I open project/solution files from Visual Studio menu, but my .xml, .cs are permanently associated with text editors.


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.