CefSharp 3 browser showing blank page - cefsharp

I have created a sample application using 64 version of CefSharp 3. It works fine while all the required libraries are in the same folder as the main application executable. I am wondering if there is a way to read the CefSharp required dlls from another path.
I am looking for a folder structure as follows
Debug\MyApp.Exe
Debug\Assemblies\CefSharp.BrowserSubprocess.exe
Debug\Assemblies\CefSharp.BrowserSubprocess.exe
Debug\Assemblies\CefSharp.Core.dll
Debug\Assemblies\CefSharp.dll
Debug\Assemblies\CefSharp.Wpf.dll
Debug\Assemblies\icudt.dll
Debug\Assemblies\libcef.dll
Debug\Assemblies\Locales\en-US.pak
in other words i need to read the required cefsharp dlls and locales from different folder than my application (MyApp.exe)
I have created the config file MyApp.exe.config as follows
<?xml version="1.0"?>
<configuration>
<!--
These settings only apply to the bootstrap AppDomain.
Modify Web.config to alter the configuration of the application.
-->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Assemblies"/>
</assemblyBinding>
</runtime>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
but still using the above browser shows blank page. it only works if all of them in one folder
Any help will be highly appreciated

I finally found the problem. due to running the browser on separate process and dependency of the CefSharp.BrowserSubprocess.exe to CefSharp.dll and CefSharp.Core.dll the same config file had to be created for the sub process.
The only change i had to make was creating the file CefSharp.BrowserSubprocess.exe.config and copy the same configuration as in MyApp.exe.config

Related

Could Not load NewtonSoft.JSON after deploying MVC app to Azure

I've deployed a MVC 4.5 web site here
However, when I view the site in browser after deployment, I have to turn custom errors off to see the following error:
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly
'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or
one of its dependencies. The system cannot find the file specified.
I ensured that CopyLocal is set to True for the DLL in my References folder. What other changes need to be made for a successful deployment?
I was having this same issue today and I'm not completely sure what I did to fix it. So I'll try giving a detailed walk through of my process.
I tried deploying a default app out of VS13 and it was too bombing with this message. FAIL.
I then removed the Newtonsoft.Json assembly and manually added the 5.0.6 version I needed. I also made sure CopyToLocal was set to true. FAIL. My sadness grows.
I enabled NuGet Package Restore. FAIL. My sadness turns to anger.
I deleted my Azure site in a fit of rage, recreated it, and the republished out again. SUCCESS!!!
So, the only logical(ish) answer I think I can give is to delete your Azure website, recreate it, and then publish again.
I hope this helps someone.
I fixed this problem by redirecting the assembly version from 0.0.0.0-6.0.0.0 to 6.0.0.0
by adding a depententAssembly in Web.config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- Add these 4 lines to Web.config, under runtime/assemblyBinding -->
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<!-- End of copy -->
</assemblyBinding>
</runtime>
<configuration>
You will find other dependentAssemblies there too, like System.Web.Mvc, WebGrease.
The newest version of Newtonsoft.Json is now 6.0.3. You may have to increase 6.0.0.0 later. Find the current newest version by looking at the version in the Solution Explorer. References -> Newton.Json -> (right click -> Properties) -> Version in the Property view
If you're sure CopyLocal is true, then the only other possibility is that you have project reference to a different assembly version than what's listed in your packages.config. Make sure the DLL version matches the version in the packages.config.

Server Error in '/' Application. This type of page is not served

I have an host where I hosted a webpage with .cshtml extension. My host is arvixe.com that provides ASP and .NET hosting but when I try to load my web page I get this error message.
Server Error in '/' Application.
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /samples/WoT/Default.cshtml
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.276
I read something does I have to write something in my web.config file to make it work
like this
<compilation>
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<buildProviders>
<add extension=".cshtml" type="System.Web.WebPages.Razor.RazorBuildProvider, System.Web.WebPages.Razor"/>
</buildProviders>
</compilation>
But I tried everything, paste it in on different lines, nothing worked. What do I miss or do wrong?
I believe you are not making using the MVC feature and trying to load just the razor view outside views or custom Area folders.
Then you need to enable webpages key in Web.config which is disabled by default in .Net 4.0
<add key="webpages:Enabled" value="true" />
<appSettings>
<add key="webpages:Enabled" value="true" />
Repairing this in Windows 10 Pro using IIS 10 was a nightmare, it took two days but I was finally able to achieve the desired results using the following procedure:
Open your web site in Visual Studio. The way you do this is to go to File > New > Web Site and then select ASP.Net Empty Web Site AND before you click OK change the location to your project location. In my case I had my project in C:\inetpub\wwwroot\AspNet\Projects\Test
Open internet information services manager (click the "cortana" search and type IIS, it should show up as long as you have it installed). Locate your project folder under the ServerName > Sites > Default Web Site > ... , right click on it and click the "Convert to web Application" button. Accepting the defaults at the prompt by clicking OK should be sufficient in most cases.
Use the following Web.Config file, or something similar. NuGet may overwrite some settings but this isn't a big problem.
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<appSettings>
<add key="webPages:Version" value="3.0.0"/>
<add key="webpages:Enabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
</assemblyBinding>
</runtime>
</configuration>
Delete your bin folder, and packages.config file, if they exist. This is because we must assume that something in that bin folder is corrupt since IIS is designed to run Razor/ASP. In your visual studio project you will need to refresh your project so it knows these files have been deleted. This can be done by clicking the refresh button in the menu on the top of the Solution Explorer frame. In you visual studio project go to Tools > NuGet Package Manager > Package Manager Console and enter the following two commands.
Install-Package Microsoft.AspNet.Razor -Version 3.0.0
Install-Package Microsoft.AspNet.WebPages
This was enough to get *.cshtml pages to be rendered by IIS 10 on Windows 10 Pro.

How to use an assembly deployed unto a custom bin folder?

MainApp/bin
There are some custom dlls here:
MainApp/bin/Custom_Dlls
I've added a probing as below to the web.config file located under the MainApp:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin;bin\Custom_Dlls" />
</assemblyBinding>
</runtime>
When I run my .aspx web page whose dll is under Custom_Dlls folder, it shows me an error message that the "Could not load type ..." which means it can't find the dll.
System.Web.HttpParseException (0x80004005): Could not load type <AssemblyName>.WebForm1'.
I've also tried using the full physical path "file:///C:\MainApp\bin\Custom_Dlls" but doesn't work.
Any help? anything else I'd need to do?
Thanks,
You can sign your assembly and deploy it to GAC. This will do the job for you.
Alternative is to load assembly at runtime. Take a look at my post for loading plugins:
VB.NET dynamic plugin components

Running web application from bin\debug folder

I'm trying to configure IIS to look for DLLs in the bin\Debug directory (as opposed to the bin directory). I tried updating my web.config, with the following line:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin\Debug" />
</assemblyBinding>
However, it still doesn't see that directory. Is there something else I am missing?
That's only for secondary assemblies. Jeff Atwood has blogged about it. You cannot entirely replace the bin folder. It just allows you to define an additional probing folder.

Registration-Free COM from ASP.NET?

Windows allows use of a COM object without having to register the COM dll.
The mechanism is to include a "dependent assembly" in the application's manifest:
MyProgram.exe.manifest
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity type="win32" name="myapp.exe" version="1.2.3.4" />
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Contoso.Frobber" version="5.1.81.4" />
</dependentAssembly>
</dependency>
</assembly>
And then your folder contains:
MyProgram.exe
MyProgram.exe.manifest (if you're using an external manifest; could also be embedded at RT_MANIFEST resource)
Contoso.Frobber.manifest (the COM DLL manifest)
confrob.dll (the dll containing the COM classes we want to use)
with the COM dll's assembly manifest containing:
Contoso.Frobber.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="Contoso.Frobber" version="1.0.0.0" />
<file name = "confrob.dll">
<comClass
progid="Frobber.Gizmo"
clsid="{00028C00-0000-0000-0000-000000000046}"
description="Gizmo Frobber by Contoso"
threadingModel = "Apartment" />
<typelib
tlbid="{00028C01-0000-0000-0000-000000000046}"
version="1.0"
helpdir=""/>
</file>
</assembly>
Excellent. i can now use a COM object from a (native or .NET) executable without having to register the COM object.
Now i want to use a COM object from an ASP.NET web-site, without registering the COM object.
Possible?
Bonus Chatter
Windows also allows an exe to call a .NET library, without having to install the .NET assembly into the Global Assembly Cache.
Although I can't test it right now I am pretty sure that this works:
IF the manifest for a DLL is external it will usually be ignored when the DLL is loaded via LoadLibrary (according to MSDN). IF the manifest is embedded into the DLL it is usually honored.
Embed the manifest into the ASP.NET application (i.e. code-behind DLL) - for some ways on how to do this see here and here and here.
UPDATE - as per comments:
The above is a workaround as there is no general way to do this (isolation), at least the ASP.NET creators haven't intended this to be possible - for example the above workaround won't work in cases where the application does not compile to a DLL...
Recently we were handling a similar case that we needed to enable Side by Side COM(reg-free COM) in IIS hosted ASP.NET core application, and we made it like:
embed the manifest to an assembly(.dll)
use CreateActCtx() to activate the manifest.
This approach works fine and it's recommended by MS .NET Runtime Interop Team.

Resources