Jump to content

Defined in assembly but not referenced


Recommended Posts

try this

1) use your IDE to create your DLL

2) look at the DotNet examples group number 4, DotNet_LoadAssembly and load your DLL like that?

If everything is built right and all the correct references made then it will work. What are you using to build your dll?

also, I don't think you can use static methods in your CS code, at least the _connect() method

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

no mate. I need the .vcsproj files and such

I would build the dll properly, then just load that assembly. you don't have to slow down to compile that way either.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

from your infomation

<ItemGroup>
    <Reference Include="Dapper, Version=1.50.5.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\packages\Dapper.1.50.5\lib\net451\Dapper.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Class1.cs" />
    <Compile Include="DataAccessLayer.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config" />
    <None Include="packages.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

we can see what all the dependencies are.

    <Reference Include="System" /> = System.dll, etc... do the rest for the rest
    <Reference Include="System.Core" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />

      <HintPath>..\packages\Dapper.1.50.5\lib\net451\Dapper.dll</HintPath>
 is your db stuff, right?

and the Microsoft.CSharp.dll so you had better be loading ALL of those if you are compiling. Look at the output directory where you get your DLL, is there any other DLLs there? you may need those at run time in the same directory

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

dude, if you are going to compile code, yes, it needs all the dependencies listed

    Local $oCode = DotNet_LoadCScode( FileRead( "..\..\AtoCLib\AtoCLib\Class1.cs" ))
you need to specify all those dlls i quoted from your vcsproj file, something like the sample I posted

Local $oCode = DotNet_LoadCScode( FileRead( "Program.cs" ), "Microsoft.CSharp.dll | System.dll | System.Core.dll | System.Data.dll | System.Windows.Forms.dll | System.Data.DataSetExtensions.dll | System.Net.Http.dll | System.Xml.dll | System.Xml.Linq.dll" ) ; You must add the "System.Windows.Forms.dll"

just add dapper to the list and that will probably work in your code.

Local $oCode = DotNet_LoadCScode( FileRead( "Class1.cs" ), "Microsoft.CSharp.dll | System.dll | System.Core.dll | System.Data.dll | System.Windows.Forms.dll | System.Data.DataSetExtensions.dll | System.Net.Http.dll | System.Xml.dll | System.Xml.Linq.dll | Dapper.dll" ) ;

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

Yeah I already tried that when i started, but i get the same errors that i do now.

And when I asked if it would help, i was replying to this.

11 minutes ago, Earthshine said:

if you want to run it as an exe, we can do that with a little mod to the source if you post the csharp code

 

Link to comment
Share on other sites

post the .cs fike and i will show you 

 

oh, did you try this?

#include "..\..\Includes\DotNetUtils.au3"

Opt( "MustDeclareVars", 1 )

Example()

Func Example()
    ; Loads a .NET assembly DLL-file into the default domain
    Local $oXPTable = DotNet_LoadAssembly( "Class1.dll" )
    If @error Then Return ConsoleWrite( "DotNet_LoadAssembly ERR" & @CRLF )
    ConsoleWrite( "DotNet_LoadAssembly OK" & @CRLF )
    DotNet_ListDomainsEx()
    DotNet_ListAssembliesEx()
    #forceref $oXPTable
EndFunc

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

as for running it as compiled code, check the snippet I posted in the other thread

class Foo
{
    public void Test(string dir, string filespec)
    {
//        if (argv.Length < 2)
//        {
//            Console.WriteLine(value: "ERROR: args = null please provide a path and a file specification to search for.");
//            Console.WriteLine(value: "Example: list c:\\ *.dll");
//        }
//        else
//        {       
            //DirectoryInfo testdr = new DirectoryInfo(path: argv[0]);
            //WalkDirectoryTree(testdr, searchname: argv[1]);
            DirectoryInfo testdr = new DirectoryInfo(path: dir);
            WalkDirectoryTree(testdr, searchname: filespec);
//        }
    }
.....
}

do it that way, not declaring it a class the way you do in your code above. and, you cannot call STATIC methods directly in your class or exe, the class itself may still access it's static methods of course, but you can't directly, notice my 'public void Test()' not public static void, you can't do it from AutoIt at least is my point. so remember do not make your entry points static. thanks.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...