Create Setup Project - Could not load file or assembly

Add-in Express™ Support Service
That's what is more important than anything else

Create Setup Project - Could not load file or assembly
 
Alex Carter




Posts: 51
Joined: 2019-02-21
Hi,
I am trying to add a setup project to my office addin however I get the error:
Could not load file or assembly 'eFiles.dll' or one of it's dependencies. is not a valid win32 application. (Exception from HRESULT: 0x800700C1).
[img]https://ibb.co/mB3Q24Z[/img]

eFiles.dll is the dll file generated for the project due to it being a class library. Am I missing something here? It is present in the bin/Debug directory but not the obj directory which I am not sure is correct?
Posted 05 Jan, 2022 05:24:18 Top
Andrei Smolin


Add-in Express team


Posts: 18185
Joined: 2006-05-11
Hello Alex,

So, the add-in project generates the eFiles.dll assembly? Do you add that assembly to your setup project?

Try to add the Primary Output of the add-in project, not the assembly itself. Check how we do this in section Creating a Visual Studio Installer setup project manually; see the PDF file in the folder {Add-in Express}\Docs on your development PC.

Regards from Poland (CET),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Jan, 2022 06:15:33 Top
Alex Carter




Posts: 51
Joined: 2019-02-21
Hi Andrei,
eFiles is the name of the project, so the name of the dll outputted for the project during the build process is eFiles.dll. I'm not really sure why it can't find this as it's a generic dll file that's outputted as part of the build process unless it's one of the dependencies that's causing the problem?

I'll have a look into the mentioned article above and see if that resolves the issue.
Posted 05 Jan, 2022 10:03:14 Top
Andrei Smolin


Add-in Express team


Posts: 18185
Joined: 2006-05-11
Hello Alex,

Do you build the add-in project for the Any CPU platform?

Regards from Poland (CET),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Jan, 2022 10:07:16 Top
Alex Carter




Posts: 51
Joined: 2019-02-21
Hi Andrei,
I build the project for x86 in the compile options. If I swap this to x64, rebuild and try to add a setup project I get a similar error however it references log4net:

"Could not load file or assembly 'log4net', Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The system cannot find the file specified.

[img]https://ibb.co/bKhRq8B[/img]

If I swap back to x86 then it gives me the eFiles.dll error again. Does this shed any light on the reason it is failing?
Posted 05 Jan, 2022 11:28:33 Top
Andrei Smolin


Add-in Express team


Posts: 18185
Joined: 2006-05-11
Hello Alex,

What Visual Studio version are you using? What occurs if you build your project for the Any CPU platform? What is the bitness of log4net?

Regards from Poland (CET),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Jan, 2022 05:43:19 Top
Alex Carter




Posts: 51
Joined: 2019-02-21
Hi Andrei,
I am using VS2022 but VS2019 also has the same issue. If I build it on any CPU platform I receive the same error regarding log4net. The log4net dll is bitness neutral (MSIL).
Posted 06 Jan, 2022 09:26:18 Top
Alex Carter




Posts: 51
Joined: 2019-02-21
Hi Andrei,
I've managed to find a way around this, it does mean that 32bit target CPU still doesn't work though. I need to add the log4net.dll file to the GAC and this then allowed me to add a setup project without error when building for target CPU's AnyCPU or x64.

However if I build for 32 bit then I still get the error regarding eFiles.dll. I am quite happy to build for x64 CPU as that's all we run these days with a 32bit version of office. However I'm still a bit confused about the error regarding eFiles.dll, surely I don't need to add this to the GAC as it's regenerated every time I build?
Posted 06 Jan, 2022 10:33:18 Top
Andrei Smolin


Add-in Express team


Posts: 18185
Joined: 2006-05-11
Hello Alex,

It looks like you have Copy Local = true on some references and this is why you see some (or all) bit-related issues.

Also, I suppose you initialize log4net in the constructor of the add-in module or in a class-level variable of the add-ion module. Try to initialize it in an Office event.

Regards from Poland (CET),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Jan, 2022 11:14:45 Top
Alex Carter




Posts: 51
Joined: 2019-02-21
Thanks for your help with this Andre. You are right, I do initialise log4net in the add-in module. I'll move this out into an office event. I think I have pretty much all references set to copy local = true too. I'll sort this out as well. I've built the project as 64bit now too so looks like the issue is resolved. Thanks for the help again!
Posted 11 Jan, 2022 03:59:21 Top