LINQPad isn't finding embedded assembly - embedded-resource

I have my own assembly where I've embedded some third party assemblies into the dll via the Vitivec Assemblies Embedder extension. These third party assemblies are all used internally and not exposed outside of my assembly.
All works fine when running the assembly under asp.net scenario, however, in LINQPad, when I reference my dll in LINQPad, it gives me an 'assembly load/not found' error for the embedded assembly and I must include a reference the third party assembly as well (even though its usage is completely private within my assembly).
The error I get is:
Could not load file or assembly '{Assmebly.Namespace}, Version=7.1.2.136, Culture=neutral, PublicKeyToken=39c186f5904944ec' or one of its dependencies. The system cannot find the file specified.
Is LINQPad unable to work in this scenario? I'd like to share my assembly and LINQPad script with others without having to also distribute the third party assembly that is already embedded into my assembly.

Related

Unity Cannot See the Scripts in Assembly-CSharp.dll assembly from a Custom Assembly Definition

I have added Assembly Definition (.asmdef) to my script folder (my custom unity scripts). Now Unity complains that it cannot find OVRInput class which I've used it in one of my scripts (GameManager.cs):
This OVRInput class is compiled into Assembly-CSharp.dll managed assembly as seen below:
I expect Unity, by default, to see this dependency and resolve it but somehow it doesn't. So I decided to manually add "Assembly-CSharp.dll" to the dependency section (called "Assembly Definition References") of my assembly but Unity gives error that it cannot find such an assembly.
The following is my custom Assembly Definition File (that puts all of scripts in "Scripts" folder into the assembly):
Target platform: Android (Oculus Gear VR)
Unity version 2018.3.13f1.
That's kind of the point
Assembly definitions are (effectively) entirely separate projects (part of the same solution, but separate dlls). This is in fact how they are displayed inside Visual Studio's Solution Explorer.
They're meant to be things you reference in to (like TextMeshPro or JsonDotNet) not out of. As such you cannot reference the main Assembly-Csharp "name space."
The advantage is that when a script file changes only its containing assembly is recompiled, instead of the entire project.
In this case, if you want to reference the Oculus files, you either need to create another assembly definition containing those files (and add it as a dependency of your first assembly) or not use an assembly definition at all.

CRM could not load file or assembly to my project

I added a reference itextsharp.dll to my plugins project, when running my plugins using plugin-registration tool I get this exception:
Could not load file or assembly or one of its dependencies. The system
cannot find the file specified
I tried removing the ref and adding it again, cleaning and then adding it to my project from different places.
Is there restrictions in plugin registration tool about adding non crm dlls? why ? how to solve it?
This is not going to work - you cannot reference external assemblies from CRM plugins that are registered in database. If you want to do this, you will have to merge your external dll with your plugin assembly. You have to remember that adding assembly as reference is not automatically making your referenced assembly available for your base assembly, therefore if you register your plugin assembly in CRM, system is not going to "magically" find somewhere your external assembly (in your case - "itextsharp.dll"). If this is not Online system, you can add your assembly to GAC, or register all your assemblies on Disk instead of database (not recommended approach). If you want to register them in database, you will have to merge everything in one assembly using ILMerge for example.
You can't reference something in a plugin unless it's in the bin of the CRM.
To make it work you need to ILmerge your reference with the plugin. Install this package in your project: MSBuild.ILMerge.Task. Then build. It will work instantly. The package will merge everything in the bin after the build. So make sure every other references are marked "Copy Local = false". Otherwise, you'll have a crazy big assembly.
Finally, Microsoft released a solution for this. You can build a nupgk file and register dependent assemblies.
Here are the white paper and my post about this;
Microsoft : Microsoft White Paper
My summary: Here is the link

Should a binding redirect work for external dlls?

Scenario:
I just upgraded all the projects in my solution to a new version of PostSharp (shouldn't matter the library, hopefully.) I have around 20 projects in my solution and around half of them originally referenced version 3.0.42 and I just updated them all to the latest version. My solution contains a web app that references projects within this solution, as well as some external dll references. It just so happens that some of those dll references also had dependencies on PostSharp version 3.0.42 and I'm now getting the typical "The located assembly's manifest definition does not match the assembly reference." error from those external dlls when trying to run my app. The web.config has the appropriate bindingdirect in place. Is there any way to have the bindingrediect impact my external dlls as well? Rebuilding them with the latest PostSharp dll is not currently an option.

Cannot load Entity Framework assembly in Azure website - The module was expected to contain an assembly manifest

I have an MVC4 web application running locally using Entity Framework 6. It is running as any CPU. When I deploy to Azure via web deploy the home page loads fine, but when I browse to a page that uses Entity Framework I see:
Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The module was expected to contain an assembly manifest.
I have tried building / deploying as X64 and x86. I have tried changing the platform mode between 32 and 64 bit in the Azure configure tab. I have tried Integrated and Classic modes. I have tried removing the package and reinstalling via NuGet.
Additionally if I try to run locally as X64 then it gives:
Could not load file or assembly 'ProjectName' or one of its dependencies. An attempt was made to load a program with an incorrect format.
This means it fails on the first page, before even getting to the page that uses Entity Framework.
How do I fix being able to use Entity Framework on Azure websites?
I had this same problem. Using FTP I noticed some unneeded DLLs in my bin folder, so I deleted all the DLLs and republished. That fixed it!

How do I deploy dlls to a system's GAC and check for their existence on program startup?

Entity Framework references some DLLs.
On one system, they showed up in the GAC which is very convenient.
I can't figure out how I did this. The installer doesn't seem to do this --
The dlls I'm specifically talking about here are:
The core library assembly Microsoft.Practices.EnterpriseLibrary.Common.dll
The Unity Application Block assembly Microsoft.Practices.Unity.dll
The Object Builder assembly Microsoft.Practices.ObjectBuilder2.dll
but I guess it applies to any dll one might want to add to the GAC.
Also is there a way to check on program startup whether an assembly even is in the GAC?
Check if is in the GAC:
bool inGac = System.Reflection.Assembly.Load(assemblyName).GlobalAssemblyGac;
To install in gac, there's a question
Methods to programmatically install a .NET assembly into the GAC