0

I want to do something to C # code executed from a script powershell. The question arose as to add a third-party library in the project?I am doing so

$path = @("C:\Users\name\Desktop\ch\packages\System.Data.SQLite.1.0.97.0")
$cSharp = @"my C# code"@
Add-Type -TypeDefinition $cSharp -ReferencedAssemblies $path

But when i start having problems running the script error:

This assembly name or codebase invalid. (Exception from HRESULT: 0x80131047).

I want to add the concrete version of the library System.Data.SQLite.dll

3
  • wouldn't be easier if you define such code in a .NET assembly and then you call it from Powershell? Jul 23, 2015 at 8:33
  • 2
    First, you can use Assembly.Load() method in your script. Second, you didn't set extension in your file: "C:\Users\name\Desktop\ch\packages\System.Data.SQLite.1.0.97.0". Try to add ".dll" "C:\Users\name\Desktop\ch\packages\System.Data.SQLite.1.0.97.0.dll"
    – Oxoron
    Jul 23, 2015 at 8:36
  • Event better would be to just Add-Type $SQLiteDll, and go from there. Assembly.Load() is not the preferred way to import libraries.
    – Eris
    Jul 30, 2015 at 3:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.