How can I fix cefsharp problem after update? - c#

I recently updated my Cefsharp.WinForms package within Nugent and it is now giving me the following error when the program tries to open a ChromiumBrowser.
System.IO.FileNotFoundException: 'Could not load file or assembly 'CefSharp.Core.Runtime.dll' or one of its dependencies. The specified module could not be found.'
I have read that this is quite a common problem so tried fixing it through the C++ Redist update and through ensuring I have all .dll files needed. I have even created a new project to test it and it works. (I then copied all the .dll files from the working project over to the one that doesn't work) but I keep getting the same problem. Any idea what next steps I can take?
ps, I have also tried to solve it by reverting back to my old version.

Related

Could not load file or assembly or one of its dependencies - searching in wrong folder?

My code was working and out of no where I am starting to get this:
System.Windows.Markup.XamlParseException: 'Could not load file or assembly 'Syncfusion.SfGrid.WPF, PublicKeyToken=3d67ed1f87d44c89' or
one of its dependencies. The system cannot find the file specified.'
FileNotFoundException: Could not load file or assembly 'Syncfusion.SfGrid.WPF, PublicKeyToken=3d67ed1f87d44c89' or one of its
dependencies. The system cannot find the file specified.
I ran fugslovw as recommended from other posts but cannot figure out how to solve this. It seems the assembly protocol is looking for Syncfusion.SfGrid.WPF.dll in the wrong directory. Syncfusion.SfGrid.WPF.dll is in the /bin/Debug folder so why isnt it searching there similar to other assemblies it found? I got this dll from nuget package and they are the same version accross my entire project. I also tried cleaning my solution. Any hints please? I have attached the two failing logs here and here. An example of a successful log which I expect is here
Probably the application (ETABS) loads your DLL with Assembly.LoadFrom, therefore resolving the dependencies works at this point in time.
When later WPF tries to load additional dependencies, it does not know about the location of your plugin and thus does not consider your bin directory.
We had a similar problem with a plugin architecture and solved it by pre-loading all required depedencies before the WPF control is created, e.g. by
_ = new AnyTypeFromTheAssembly();

Consume all source code (non-compiled) from one project into another (PDFSharp)

As the title says, I want to consume all of PDFSharp's source code into my own project. But let me explain why I came to this scenario, so if there is something else I can do, maybe there are other options.
Goal: Compile my project into a single .exe file to use. No installers.
Problem: It uses PDFSharp.dll which is causing me issues.
What I am trying to do, is use ILMerge to create the .exe. I've used this successfully in the past for other projects.
The issue I think is that ILMerge is requiring references to other assemblies that PDFSharp uses. The first being Microsoft.ApplicationInsights. So to by-pass this, I installed Microsoft.ApplicationInsights into my project via Nuget. Then removed the actual reference from the project, but referenced the library in my ILMerge command as below:
/lib:"C:\<path to assembly>\Microsoft.ApplicationInsights.2.16.0\lib\net46"
This actually worked. Except, now it asked for another library and I get this error:
Unresolved assembly reference not allowed: GdPicture.NET.11.
This looks like a paid library, perhaps downloading the trial may get me past this. I didn't try yet. I switched gears as I felt I may be trying to reference an endless amount of assemblies.
I then tried to get the PDFSharp source code and I found that version 1.32 here:
https://sourceforge.net/projects/pdfsharp/files/pdfsharp/PDFsharp%201.32/
I added a reference to this project within my solution file, so now I have a solution with 2 projects. Great.
I then I tried to link source files into my project. How to do that is here:
https://jeremybytes.blogspot.com/2019/07/linking-files-in-visual-studio.html#:~:text=To%20link%20files%2C%20use%20the,CLICK%20THE%20%22Add%22%20BUTTON.
This seems to work, but every file I add requires another file, which references another file etc. It seemed endless. So that led me to the idea of just consuming the entire source code into my project and I haven't seen a good way to do that yet. I can't add a reference to the project as it just references the compiled dll which again, iLMerge can't combine.
I've also tried updating the tag within the .csproj file of PDFSharp to "module" to create a .netmodule file. This creates the file in the obj directory but throws an error:
\PDFsharp\code\PdfSharp\obj\Release\PdfSharp.netmodule' is not an assembly
Any help is appreciated. thanks.
UPDATE: I reversed everything and added the PdfSharp reference - back to where I was and changed my project to module and built which created a .netmodule file. Then used the assembly linker to create a .exe from that file. That worked using this command from VS Dev prompt.
al MyModule.netmodule /target:exe /out:MyProgram.exe /main:MyNamespace.MyClass.Main
This created the .exe, but when run without any other supporting files produces a file not found error:
System.IO.FileNotFoundException: Could not load file or assembly 'MyModule.netmodule' or one of its dependencies. The system cannot find the file specified.
Which is interesting since the module should be inside the exe right?
I have this working now, so I just wanted to place my results here since it is already posted.
My initial problem was that I mistakenly thought the PDFSharp.dll was causing the issue, but it was actually another group of 3rd Party dlls I was referencing.
I tried for hours to get iLMerge to work with the only success being it would kick out a single .exe file but it would have runtime errors.
Errors that I encountered:
Error: Unresolved assembly reference not allowed: Custom.Assembly.
Solution: Reference the assembly if possible. If you have many, you can reference a folder with the /lib:"C:\folderpath" switch.
Error: Unresolved assembly reference not allowed: ADotNetFramework.dll.
Solution: You can reference the desired .Net Framework path where iLMerge will search for missing references. Example: /targetplatform:"v4,C:<Path To Framework>.NETFramework\v4.8"
Error: The assembly 'xyz.dll' was not merged in correctly. It is still listed as an external reference in the target assembly.
Solution: You can get past this error with the /closed switch. However, I don't think I should even have gotten this error because 'xyz.dll' was a referenced dll to be combined.
Also - use the /log switch, it is extremely helpful in seeing exactly what iLMerge is doing and figuring out your issue. Example: /log:mylog.txt
This allowed me to see that iLMerge was finding duplicate namespaces, in the 3rd Party assemblies and automatically renaming them. Here is an example from my log:
Merging assembly 'My.Assembly.Name' into target assembly.
Duplicate type name: modifying name of the type '<>f__AnonymousType02' (from assembly 'My.Assembly.Name') to 'My.Assembly.Name.<>f__AnonymousType02'
Duplicate type name: modifying name of the type '<>f__AnonymousType12' (from assembly 'My.Assembly.Name') to 'My.Assembly.Name.<>f__AnonymousType12'
Duplicate type name: modifying name of the type '' (from assembly 'My.Assembly.Name') to 'My.Assembly.Name.
Finally - the solution that I found was not to use iLMerge. I found this Answer: https://stackoverflow.com/a/40786196/2596309
which used Costura.Fody
I installed the nuget package with:
Install-Package Costura.Fody -Version 4.1.0
Cleaned and built my solution and it created a single .exe file that I tested and it worked. Literally, I put 3 days of work into this and the solution took 3 minutes...

WiX installer project: CefSharp.Core.dll could not be loaded, file not found

I am working on a windows application on c# visual studio, i have set up a WiX project for the installer and have added CefSharp, CefSharp.Core, CefSharp.Wpf references to it also.
However, upon building, it throws an error that the extension
'..\packages\CefSharp.Common.57.0.0\CefSharp\x86\CefSharp.Core.dll' could not be loaded because of the following reason: Could not load
file or assembly 'CefSharp.Core.dll' or one of its dependencies. The
specified module could not be found. InstallProj candle.exe 0
The file exists in that directory but for some reason it cannot be loaded. I have tried referencing both x64 and x86 but to no avail. But when I unload the WiX project and build, the error does not occur build successfully.
I have browsed a lot of similar questions where this dll could not be loaded but none helped fix my issue. I have tried reloading the dependencies
Edit:
I tried removing the references and uninstalling the CefSharp.Common and CefSharp.Wpf packages from InstallProj. It still tries to load the dll with the same error.
As written in the comments, I downgraded from WiX toolset v4.0 to v3.11 and fixed it in this case

Compiled program searching for and not finding project which is part of solution

I've created a commandline program which I'm compiling and executing. So far so good.
The solution consists of 2 projects. The main project and the data project (with the main project being the executeable and startup proejct and the data project handling the sql connections).
It works fine BUT: Whenever I move the .exe out of the folder it has been created in it tries to find the data project and fails to do so and thus the execution of the .exe fails.
The error message is:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or
assembly 'Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or
one of its dependencies. The system cannot find the file specified.
at MyProject.Program.Main(String[] args)
I've never encountered this problem before as both projects are part of the same solution and in the compile folder it works.
Anyone can give me a hint as towhat could be the cause here?
Notes: The project itself has the default settings as has the solution.
Also like mentioned I have never encountered such a problem before as normally I only just move the .exe and don't need to also move (separately) the .dll of the other projects. At least I never consciously encountered this problem before there. If I included external projects then yes then it was necessary to also have the .dll there if I said reference by copy. But in this case its a second project of the same solution and there I never had this before.

Visiblox invalid assembly reference

I am struggling with a problem regarding to visiblox. I am quite new to the WPF concept, but I am getting the hang of it. I have quite some expirence with the classic forms.
My problem is that the designer keeps telling me that the XAML contains errors. And I get the folling error in my error list:
Unable to load the metadata for assembly 'Visiblox.Charts'.
This assembly may have been downloaded from the web.
See http://go.microsoft.com/fwlink/?LinkId=179545.
The following error was encountered during load: Could not load file or assembly
'Visiblox.Charts, Version=2.1.4.31043, Culture=neutral, publicKeyToken=1543c03f04c4461b' or one of its dependencies.
I have added the reference to the project, and I have added the line:
xmlns:charts="clr-namespace:Visiblox.Charts;assembly=Visiblox.Charts"
I can build and run the project, but the designer keeps telling me that my assemblies are not correct. I tried to clean and rebuilt the project. Restarted Visual Studio and the computer, but nothing seems to work. Anyone any clue? Thank you in advance.
I'd suggest following the link it provides: http://go.microsoft.com/fwlink/?LinkId=179545
The problem is that the dll is "locked" by windows security and you need to unlock it before you can reference it. The link specified tells you how.

Categories

Resources