I've recently finished converting a WPF project to the new csproj format which is much leaner.
However I have one missing piece left, adding a probing path for the assemblies, something that used to exist in the old app.config file. With this missing my application just doesn't find the required dlls.
The way I have this set up is with a Post-build event that clears and moves items to a bin folder:
SET folder=bin
rmdir "$(TargetDir)%folder%" /s /q
mkdir "$(TargetDir)%folder%"
move "$(TargetDir)*.dll" "$(TargetDir)%folder%\"
I've tried adding some entries to the .csproj file but to no avail. I believe this is more for compiling the application:
<PropertyGroup>
<ReferencePath>bin</ReferencePath>
</PropertyGroup>
<PropertyGroup>
<AssemblySearchPaths>
$(AssemblySearchPaths);
$(ReferencePath);
</AssemblySearchPaths>
</PropertyGroup>
I guess my main question, should I still have an app.config, or is there a better .csproj approach available?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin"/>
</assemblyBinding>
</runtime>
</configuration>
My application will work if I include it, but I'd like to know if I can simplify this, or do this in a better way in general.
Related
I'm using Visual Studio 2019 Community Edition. After I added the reference under subdir with copy local set to true, it works fine, then I modified the app.config to
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Mylib\"/>
</assemblyBinding>
</runtime>
</configuration>
thinking this may not require copy to local anymore, then I got
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Isn`t this the proper way to add subdir reference? (By the way, there is only *.dll.config but not *exe.config generated when I added item 'App.config' )
I finally found out that the problem here is the project type part, it seems that .net core does not support these traits, so I changed my project to console(.netframework) then the modifying app.config route works.
I just tried to install CefSharp on a new winForm application, i install the latest version with Nuget and done all the steps by this article:
https://ourcodeworld.com/articles/read/173/how-to-use-cefsharp-chromium-embedded-framework-csharp-in-a-winforms-application
Running on : "Any CPU"
Visual Studio 2013
CefSharp 69.0.0
When i run the application i get this error:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies. The specified module could not be found.
This is the code:
var settings = new CefSettings();
Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
Any idea what is the problem?
EDIT
This is the app.config file of my project:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="x86"/>
</assemblyBinding>
</runtime>
</configuration>
In our case this happened when we failed to install the Visual C++ runtime.
In app.config file , please check dependentAssembly segment for CelfSharp.
If it has any entry, make sure that the version of added reference be in valid range.
When i build the solution , it was always create some assembly XML files,How should i disable auto create them?Thanks.
Also , i was set the privatePath, but the NuGet item (dll) cannot build in the privatePath. How should i setting?
App.Config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Bin" />
assembly XML files:
Dapper.xml
Dapper.SimpleCRUD.xml
...
When compiling a C# project which has external references, the referenced dlls are being copied to the project's output path (next to the exe).
When running the application, it expects to find the dlls next to the exe.
I'm looking for a way to spread my dll files into different directories Dlls for starters). And have the exe look for the dll files in those directories.
Example:
Let's say we have an application called "App" located under C:\App\App.exe, and also it uses a dll file called "App.dll" which is currently also located under C:\App.
I wish to create a new directory called C:\App\Dlls and move the App.dll file to there, while making sure that the App.exe file will know to look for the dll in the new location.
I've searched the internet and found the probing solution. Here's my code (edited "App.config" file):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas=microsoft-com:asm.v1">
<probing privatePath="Dlls" />
</assemblyBinding>
</runtime>
</configuration>
I compiled my application, created the Dlls directory and moved all the dll files to that directory, but the application crashes.
What am I missing?
Found the solution, the file App.exe.config was missing from my base directory. That's why it didn't work. Now everything works smoothly.
When building my WPF application all internationalization/locale folders are put inside the folder of the executable.
/MyApp
/MyApp/de
/MyApp/fr
/MyApp/otherSpecialFolder
/MyApp/...
The problem is that this mixes up with some other folders. Is it possible to put the internationalization into a separate folder and let the Wpf app search there instead? For example:
/MyApp
/MyApp/i18n/de
/MyApp/i18n/fr
/MyApp/otherSpecialFolder
/MyApp/...
This problem occurs not only for own localization ressources but also when adding thirdparty controls like Xceed.Wpf.AvalonDock.
Yes you can. You just have to add probing element into your App.config.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="i18n"/>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
probing element specifies the path where assemblies are searched for.