I am trying to run a simple WPF application (x86) using CefSharp WPF (75.1.141) in VirtualBox Windows 10 x64, but it crashes when I try to render a web browser.
It runs normally on the developer's machine Windows 10 x64 using Visual Studion 2017 WPF compiling in .Net Framework 4.5.2.
I already tried changing Cefsharp version to 71.0.0 but it didn't help. Also I tried cefsharp settings with commandline arguments "disable-gpu", "no-proxy-server", nothing changed.
Here are the MainWindow.xaml.cs code
ChromiumWebBrowser browser;
public MainWindow()
{
InitializeComponent();
Init();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (Init())
{
if (browser == null)
{
browser = new ChromiumWebBrowser();
((ChromiumWebBrowser)browser).IsBrowserInitializedChanged += (s, e2) =>
{
if (((ChromiumWebBrowser)browser).IsBrowserInitialized)
{
((ChromiumWebBrowser)browser).Load(textbox_url.Text);
}
};
gridBrowser.Children.Add(browser);
}
else if (((ChromiumWebBrowser)browser).IsBrowserInitialized)
{
((ChromiumWebBrowser)browser).Load(textbox_url.Text);
}
}
}
static bool init = false;
private bool Init()
{
if (init) return true;
//Monitor parent process exit and close subprocesses if parent process exits first
CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
var settings = new CefSettings()
{
//By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
CachePath = "cache",
IgnoreCertificateErrors = true,
};
init = Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
return init;
}
~MainWindow()
{
if (browser != null)
{
((ChromiumWebBrowser)browser).Dispose();
}
}
Event Viewer shows these errors
1. Info
Error container 1258037397975457498, type 1
Event name: APPCRASH
Response: No data
CAB ID: 0
Problem signature:
P1: CefSharpTest.exe
P2: 1.0.0.0
P3: a8760476
P4: VBoxDispD3D-x86.dll
P5: 6.0.4.28413
P6: 5c4b57a6
P7: c0000005
P8: 0000fb19
P9:
P10:
Included files:
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERCA7F.tmp.dmp
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERCC07.tmp.WERInternalMetadata.xml
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERCC15.tmp.csv
\\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERCC26.tmp.txt
These files can be found here:
C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_CefSharpTest.exe_87545299969ed877b3362d6ccde2f935ae9a282_7a64911f_0491dc52
Analyze symbol:
Repeated search for the issue: 0
Report Id: 011981c1-b0ed-4e02-b4fe-0361ef1885de
Report Status: 268435456
Hashed container: 952737448bb5f0a7517572591c7bdeda
2. Critical
Application: CefSharp.BrowserSubprocess.exe
Platform version: v4.0.30319
Description. The process was completed due to an unhandled exception..
Exception Details: exception code e0000008, exception address 76570882
3. Critical
Name of failed application: CefSharpTest.exe, version: 1.0.0.0, timestamp: 0xa8760476
Failed module name: VBoxDispD3D-x86.dll, version: 6.0.4.28413, timestamp: 0x5c4b57a6
Exception code: 0xc0000005
Error offset: 0x0000fb19
ID of the failed process: 0x1198
Failed application Launch Time: 0x01d55c59eed8c47d
Bad Application Path: C:\Users\Евгений\Desktop\CefSharpTest\CefSharpTest.exe
Failed module path: C:\Windows\SYSTEM32\VBoxDispD3D-x86.dll
Report Id: 011981c1-b0ed-4e02-b4fe-0361ef1885de
Failed Package Full Name:
Bad Package Application Code:
I also tried with installed vc++ (but I wanted without). I finally managed this to work by building with cefsharp version 67.0.0 and copying msvcp140.dll and vcruntime140.dll along with .exe. Thank you for your reply anyway.
Related
I have some server app. This app run, read some files, create C# classes, build this and load assembly. This app can work in two modes - one mode is window desktop application, and other mode - as windows service but core in dll is common.
Sometimes when this app work long time as service, and machine server has long timeup, they can't build anything. I attach to debugger, and debug. I debug .NET source (CompileAssemblyFromSource), and I see, that .NET classes just run csc.exe process with some params (CSharpCodeProvider class), but csc.exe run, return no errors or exceptions, output is blank and nothing is happend. No assembly is build.
I wrote some dump test service to compile code:
namespace CompilerService
{
public class Compiler
{
private Task _compilerTask;
public Compiler()
{
_compilerTask = Task.Run(() => CompileHalloWorld());
}
private const string _workingDir = #"C:\tmp";
private void CompileHalloWorld()
{
System.Threading.Thread.Sleep((30000));
if (!Directory.Exists(_workingDir))
{
Directory.CreateDirectory(_workingDir);
}
Directory.SetCurrentDirectory(_workingDir);
var csc = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v4.0" } });
var parameters = new CompilerParameters(new[] { "mscorlib.dll", "System.Core.dll" }, "foo.exe", true);
parameters.GenerateExecutable = true;
CompilerResults results = null;
try
{
results = csc.CompileAssemblyFromSource(parameters,
#"using System;
class Program {
public static void Main(string[] args) {
Console.WriteLine(""Hallo World!"");
}
}");
}
catch (Exception e)
{
int a = 2;
}
results.Errors.Cast<CompilerError>().ToList().ForEach(error => Console.WriteLine(error.ErrorText));
}
}
}
This dump service is fail too with build hallo world in this state of machine.
After restart machine, all work again ok, compile and load assembly all the time. After few weeks, problem come back, and we must reset server. This problem is on only one machine. On otger machines this service and csc.exe work perfect from years.
If machine is in this wird state, csc.exe dont build in windows service app, but when We run this app as Windows Desktop App all work fine, and csc.exe build normal...
Can you tell me, this is some known issue, oraz is some solution of don't compile csc.exe without machine restart?
I'm developing a UWP application which shall be able to share its files. I followed the documentation from Microsoft and the solution worked pretty well.
Here is my implementation:
public void ShareLocalFile(LocalFileToShare file)
{
DataTransferManager.GetForCurrentView().DataRequested += async (sender, args) =>
{
var deferral = args.Request.GetDeferral();
try
{
var storageFile = await StorageFile.GetFileFromPathAsync(file.FilePath).AsTask();
args.Request.Data.SetStorageItems(new[] { storageFile });
}
finally
{
deferral.Complete();
}
};
DataTransferManager.ShowShareUI();
}
However, the app stores all files with not human-readable names which makes users be uneasy with the sharing.
So, I wanted to share a file with an alternative name without actually renaming it on the file system because files are opened in a third-party reader. In addition, the files are quite big and copying them with new names is not a good choice.
Firstly I thought that I could make a symbolic link but it's only possible with Administrator rights
Then I looked at the signature of "void DataPackage.SetStorageItems(IEnumerable value)" method and guessed that it's probably possible to pass there my own implementation of IStorageItem what I did:
public class StorageItemWithAlternativeName : IStorageItem
{
private readonly IStorageItem storageItem;
public StorageItemWithAlternativeName(IStorageItem storageItem, string alternativeItemName)
{
this.storageItem = storageItem;
Name = alternativeItemName;
}
public string Name { get; }
// the interface implementation omitted for briefness but it simply delegates all actions to the decorated storageItem
}
public static class LocalFileToShareExtensions
{
public static async Task<IStorageItem> GetStorageItem(this LocalFileToShare file)
{
var storageFile = await StorageFile.GetFileFromPathAsync(file.FilePath).AsTask();
if (!string.IsNullOrWhiteSpace(file.AlternativeFileName))
{
storageFile = new StorageItemWithAlternativeName(storageFile, file.AlternativeFileName);
}
return storageFile;
}
}
And here I failed. The error is quite silly - SetStorageItems method throws an InvalidCastException:
"No such interface supported.
The collection contains item(s) that can't be converted to read-only form."
I investigated the windows event log and found the following entry:
Faulting application name: [MyApp].Windows.exe, version: 7.0.0.0, time stamp: 0x5bb69bfe
Faulting module name: combase.dll, version: 10.0.17763.253, time stamp: 0xa3f81b2d
Exception code: 0xc000027b
Fault offset: 0x00209931
Faulting process id: 0x4ee4
Faulting application start time: 0x01d4be3ccca1f00f
Faulting application path: [PathToMyApp].Windows.exe
Faulting module path: C:\WINDOWS\System32\combase.dll
Report Id: 35999df1-6b4f-4675-a821-a84e6ea0cfb4
Faulting package full name: [MyAppPackageName]
Faulting package-relative application ID: App
It seems that the DataPackage object communicates with COM so I also tried [assembly: [ComVisible(true)] attribute on my assembly but I did not succeed.
The question is how can I kind of dumb the system and share a file with a different name? Is it possible to pass my own implementations to UWP SDK methods? Because now it violates the Liskov substitution principle.
I will appreciate any help with this!
Please try to use the overloaded method SetStorageItems with parameter readOnly:false, something like this:
args.Request.Data.SetStorageItems(new[] { storageFile }, false);
I have the Brother QL-700 label printer and i have installed latest B-PAC SDK V3.2.001 64bit which was released end of last month. Also i have installed "B-PAC client component" on my windows 10 64 bit computer as well. Given template file(addr.LBX) prints successfully from P-touch Editor 5.2.
However B-Pac sdk faild to print from below C# program. It gives below error when executing the given code snippet,
'NamePlt.vshost.exe' (CLR v2.0.50727: NamePlt.vshost.exe): Loaded 'C:\Program Files\Brother bPAC3 SDK\Samples\VCS\NamePlt\bin\Debug\Interop.bpac.dll'. Module was built without symbols.Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Any support highly appreciated!
private const string TEMPLATE_DIRECTORY = #"C:\Program Files\Brother bPAC3 SDK\Templates\"; // Template file path
private const string TEMPLATE_FILE = "addr.LBX"; // Template file printing fine from the P-touch Editor
public Form1()
{
InitializeComponent();
}
private void btnPrint_Click(object sender, EventArgs e)
{
string templatePath = TEMPLATE_DIRECTORY;
templatePath += TEMPLATE_FILE;
bpac.DocumentClass doc = new DocumentClass();
if (doc.Open(templatePath) != false)
{
//doc.GetObject("objCompany").Text = txtCompany.Text;
//doc.GetObject("objName").Text = txtName.Text;
// doc.SetMediaById(doc.Printer.GetMediaId(), true);
doc.StartPrint("", PrintOptionConstants.bpoDefault);
doc.PrintOut(1, PrintOptionConstants.bpoDefault);
doc.EndPrint();
doc.Close();
MessageBox.Show("Error code : " + doc.ErrorCode);
}
else
{
MessageBox.Show("Open() Error: " + doc.ErrorCode);
}
}
I have a .net application that references the Microsoft.SqlServer.Smo assembly.
The assembly is not distributed with the application. Instead the sql sdk is installed in the system and the dll is registered in the GAC so that the application can load.
There is no problem with this except that on some target machines I have the v12 of the SDK, while on others I have the v13 of the SDK (that usually comes installed with SSMS).
I would like the application to load the latest version of whatever is available on the system, so v13 or, if not available, v12.
Is it possible to achieve this in code or through the application config?
The short answer to the question is to set SpecificVersion to false as correctly suggested by #sevzas.
Anyway, if on the system is installed SSMS 2016 update 13.0.16000.28, the 13.100.0.0 of the dll will be registered in the GAC and with the above change, this is the version that it will be loaded. Unfortunately this version is not meant to be used by 3rd party developers but only by Microsoft products, so trying to load it will generate an exception (see here). Someone could wonder at this point why they register it in the GAC if they don't want people to use it.
Anyway, I found a way to load the v13.0 (or previous, or future 14) with the below code by using the assembly resolve event.
static int Main(string[] args)
{
//we set an event handler at the begging of our program
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
//your stuff
}
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
//if the dll is a sqlserver dll, we do our trick
if(args.Name.StartsWith("Microsoft.SqlServer"))
return LoadSqlAssembly(args.Name);
return null;
}
private static readonly int[] SqlVersions = new int[] {14, 13, 12, 11};
private static bool _reEntry = false;
private static Assembly LoadSqlAssembly(string name)
{
if (_reEntry)
return null;
name = name.Split(',')[0];
foreach (var version in SqlVersions)
{
try
{
_reEntry = true;
var ret = Assembly.Load($"{name}, Version={version}.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL");
//Logger.InfoFormat("Loaded {0} version {1}", name, version);
return ret;
}
catch (Exception)
{
//ignore exception
}
finally
{
_reEntry = false;
}
}
return null;
}
```
I have an XNA project I have that compiles perfectly fine in Visual Studio 2015, that makes use of C# 6 features.
Previously, I had some tools coded in C# that would auto-compile the project when it was using C# 5 under VS 2013, but the change to C# 6 has broken things somehow.
To reproduce this I created a new console application, referenced Microsoft.Build, Microsoft.Build.Framework, and Microsoft.Build.Utilities.Core assemblies from C:\Program Files (x86)\MSBuild\14.0\Bin.
I then created my C# compiler project with the following code:
namespace CompileXna
{
class Program
{
static void Main(string[] args)
{
const string solutionPath = #"D:\Code\My Projects\FrbTest\FrbTest.sln";
var properties = new Dictionary<string, string>()
{
{"Configuration", "Debug"},
{"Platform", "x86" }
};
var parameters = new BuildParameters
{
Loggers = new ILogger[] {new BuildLogger()}
};
var request = new BuildRequestData(solutionPath, properties, null, new string[] {"Build"}, null);
var manager = BuildManager.DefaultBuildManager.Build(parameters, request);
Console.WriteLine("Done");
Console.ReadLine();
}
}
class BuildLogger : Logger
{
public override void Initialize(IEventSource eventSource)
{
eventSource.ErrorRaised += (sender, args) =>
Console.WriteLine($"Error: File {args.File} line {args.LineNumber} message {args.Message}");
eventSource.WarningRaised += (sender, args) =>
Console.WriteLine($"Warning: File {args.File} line {args.LineNumber} message {args.Message}");
}
}
}
Unfortunately, when this runs I get the following error:
Error: File C:\Program Files (x86)\MSBuild\Microsoft\XNA Game Studio\v4.0\Microsoft.Xna.GameStudio.ContentPipeline.targets line 78 message The "BuildContent" task could not be instantiated from the assembly "Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent' to type 'Microsoft.Build.Framework.ITask'.
I tried looking in the details of the build output in Visual Studio 2015 when it successfully compiles my XNA project, but even with Detailed logging all I could find (seemingly) relevant was:
1>Using "BuildContent" task from assembly "Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553".
1>Task "BuildContent"
1>Done executing task "BuildContent".
Anyone have any success on this?