2
votes

Background

I'm building a mobile app for an existing DNN 7 site; made by someone else who left a year ago or so. I had previously set up a WebApi module to handle authentication. Then I had the idea of setting up a class library to hold my DTO objects; since I would have to modify several existing modules to expose web methods and they'd have to interact with my app. So I created a class library threw in two classes and compiled. Added the dll reference to both my app and the web module and they have no issues building when referencing my objects. However, when I send a web request, from either my app or Postman chrome extension, to my module I get:

"Could not load file or assembly 'Elf.Web.Models, Version=1.0.6081.13955,   Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.",

My app doesn't seem to have issues creating and using the objects, just with the web module.

What I Tried/Checked

Properties I made sure both my class library and my web module were targeting the same framework; .NET Framework 4.5

Reference Property Copy Local is True and per Other Question I tried manually editing my .csproj file to add the attribute Private to True under my reference. I even tried adding a binding redirect to my assembly.

Manual I also tried opening up my modules install zip tossing the class library dll into the bin folder, re-zip, and then installed to the dnn site. The problem persisted.

If anyone else has an idea of what could be an issue it'd be appreciated.

1

1 Answers

1
votes

Putting the library dll in the bin folder of the installer zip file will not automatically put your library dll file into the bin folder of the DotNetNuke installation during install.

Add this to the installer .dnn file under the <components> node.

<component type="Assembly">
  <assemblies>
    <assembly>
      <name>myLibrary.dll</name>
      <path>bin</path>
    </assembly>    
  </assemblies>
</component>

If you want the file to be added to the installer zip automatically, you have to make a reference in the ModulePackage.targets file.

<Copy SourceFiles="$(MSBuildDnnBinPath)\myLibrary.dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>