0

I have a problem. I have inserted parts of an already existing program into our program. I have adjusted all references, nuggets, namespaces etc and the program is already running on my PC. Then when I passed it to our tester, it crashed. The reason is that it does not find the System.Drawing.dll. While troubleshooting, I found out that this dll is in my GAC. After deleting it, the program crashed on my PC as well. In the referenced folder is the System.Drawing.dll. I don't understand why the program is trying to load it from the GAC and not from the referenced folder.

I have tried several solutions from other threads. E.g. copy locally = true, set specifc version = true,

Additionally, I tried putting the DLL directly into the output folder. In doing so, I noticed that the program works with dll version 2.0.0.0 and not 4.0.0.0, which is referenced. However, I did not specify a particular version.

Exception message: (sorry for german)

EXCEPTION: System.IO.FileNotFoundException: Die Datei oder Assembly "System.Drawing, Version=2.0.0.0, Culture=neutral oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden. Dateiname: "System.Drawing, Version=2.0.0.0, Culture=neutral ---> System.IO.FileNotFoundException: Die Datei oder Assembly "System.Drawing, Version=2.0.0.0, Culture=neutral oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden. Dateiname: "System.Drawing, Version=2.0.0.0, Culture=neutral bei System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) bei System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) bei System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) bei System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) bei System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) bei System.Reflection.Assembly.ReflectionOnlyLoad(String assemblyString) bei Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.OnReflectionOnlyResolve(ResolveEventArgs args, DirectoryInfo directory) bei Prism.Modularity.DirectoryModuleCatalog.InnerModuleInfoLoader.<>c__DisplayClass0_0.b__0(Object sender, ResolveEventArgs args) bei System.AppDomain.OnReflectionOnlyAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

Edit 1: Application is written in .net 4.7.2 XML Snippet:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\PropertyChanged.Fody.3.2.8\build\PropertyChanged.Fody.props" Condition="Exists('..\packages\PropertyChanged.Fody.3.2.8\build\PropertyChanged.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Management" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
</Project>

Temporary Solution I created a postbuild event, which copied the System.Drawing.dll in the output folder. So the program is running now, but I don't like this solution, because it doesn't fix the bug.

Andreas
  • 1
  • 1

0 Answers0