none
T4 templates and native dll RRS feed

  • Question

  • Hello!

    I am trying to use a C++/CLI assembly from T4 template by <#@ assembly name="path-to-c++/cli-dll"#> directive. The problem is that C++/CLI assembly imports native dll and as a result I have following exception on template transformation attempt:

     

    Error 8 There was a problem loading the assembly 'c:\tfs\sms\DeveloperBranch\CodeGen\Bin\x86d\Sms.Data.Wrapper.dll' The following Exception was thrown:
    System.IO.FileNotFoundException: Could not load file or assembly 'Sms.Data.Wrapper.dll' or one of its dependencies. The specified module could not be found.
    File name: 'Sms.Data.Wrapper.dll'
       at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
       at System.Reflection.Assembly.LoadFrom(String assemblyFile)
       at Microsoft.VisualStudio.TextTemplating.TransformationRunner.AttemptAssemblyLoad(String assemblyName)

     

    ('Sms.Data.Wrapper.dll' is a C++/CLI assembly here.)

    When all parts referencing to native code are deleted from Sms.Data.Wrapper.dll, exception vanishes. That confirms my assumption that problem is related somehow to native code.

    Have any one experienced a problem like this before? Any suggestions are welcome.

    Alexander

    • Moved by lucy-liu Monday, January 16, 2012 3:58 AM it is a clr issue (From:Visual Studio Extensibility)
    Thursday, January 12, 2012 1:40 PM

All replies

  • Hi Alexander,

    This issue is more related to Common Language Runtime , I will move it to “Common Language Runtime” forum for a better support. Thank you for your understanding!

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 16, 2012 3:56 AM
  • Hi,

    May I know how do you import methods in the native dll?

    We always P/Invoke native assembly as below:

    http://msdn.microsoft.com/en-us/library/aa288468(v=VS.71).aspx

    Firstly, you need to ensure that the path of the dll is correct. I see "c:\tfs\sms\DeveloperBranch\CodeGen\Bin\x86d\Sms.Data.Wrapper.dll". Are you just making a mistake of the wrong path?

    Moreover, if it is not issue about the path, could you please provide some code snippet(both managed and native) to help us reproduce this issue?

    Thanks.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 16, 2012 9:31 AM