Azure Web App with assembly containing C++/CLI - asp.net

I have some existing functionality in unmanaged C++ which I wanted to use in a Web App. This code was already wrapped in C++/CLI and used via desktop C# apps. So there is already an existing mixed mode .NET assembly containing the functionality I want to use in a Web App. I also already have Azure hosted web apps that are composed of assemblies containing only C# and I can publish them from Visual Studio 2017 to an Azure App service with no problem.
So I tried to add the mixed mode assembly and started getting errors from the publish about the dependencies of the mixed mode assembly. The only dependency of the mixed mode assembly is on the VC++ runtime so I assumed that was the problem. To prove this I created an Azure VM started IIS on it and published to that and got exactly the same error. I then installed the VS 2017 C++ runtimes on the VM and published again. The error went away and the Web site works fine.
I them logged onto the machine hosting the Web service using Kudu and it appears to have the VS 2017 C++ run time already installed. So I am baffled why I get the error when I publish to it. I have tried adding the runtime DLL's like vcruntime140.dll to my publish but this didn't fix things. I also tried re-installing the runtimes with no luck.
So does anyone have any insights as to why I am getting DLL dependency errors and what I can do to fix it. Ideally I was hoping for a Hello World example of using C++/CLI in a Web App from Microsoft but have not been able to find one.
Note there is a similar question here multi-file c++/cli .net assembly in ASP.NET web site without an answer.

Related

Error System.NotSupportedException on Razor Pages Project

After researching a lot and finding nothing about it, I decided to ask for collaboration here in the community.
I am trying to perform run in Visual Studio 2019 from a Razor Pages project, created in the 2017 version of Visual Studio. The Target Framework is net461.
However, the following error occurs:
NotSupportedException: Attempting to load an assembly from a network
location that would cause the assembly to be in safe mode in earlier
versions of the .NET Framework. This version of the .NET Framework
does not enable CAS policy by default, so this loading can be
dangerous. If it does not intend to confine the assembly, enable the
loadFromRemoteSources option.
I am not loading any assemblies over the network. All files are on my computer. Also, all exe, dll files are unlocked.
Error is in the startup.cs:
services.AddMvc()
I greatly appreciate any help.
are you creating .NET 4.6.* project or .Net Core? For .Net Core the target framework should be .NET Core 2.* or 3.* and make sure SDK is installed on your machine.

Having trouble referencing .NET Standard class library using SQLProvider from .NET Core project

Reproduction of problem here: https://github.com/Arrow7000/SqlProviderTest
I'm fairly new to the .NET world so am having trouble wrapping my head around exactly what the problem is.
I've tried to use the SQL type provider directly in an F# .NET Core project, but had a bunch of problems getting it to work. From what I can tell that's due to incompatibilities between .net core and type providers.
So what I am trying instead is to have the SQL type provider code encapsulated in a .NET Standard project that I can reference from my main Core project.
I've managed to reproduce the problem in a minimal GitHub repo located here which demonstrates both that
the type provider is working in Visual Studio 2019 with IntelliSense, but
despite this I still get a build error when I try to start the Main project
The build error is
Unable to find the file 'C:\projects\SqlProviderTest\SQLStuff\bin\Debug\netstandard2.0\SQLStuff.dll' in any of
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\ref\netcoreapp2.2
C:\projects\SqlProviderTest\Main
C:\Users\Aron\.nuget\packages\fsharp.core\4.6.2\lib\netstandard1.6
Why isn't the project reference simply working as expected? I've tried adding <Private>True</Private> to the project reference but that didn't make any difference
P.S. in case it matters, I'm developing on Windows but the app gets deployed on a Docker container.

Azure .Net WebApp Deployment Failed but it works locally on VS

I am new to .Net and Unable to understand some weird behaviour with Azure.
I am trying to publish a .Net Project to Azure Web App. And It is throwing very silly errors. I assume thats becoz of new C# version.
Here is the log file.
Use Case 1: When trying to build from Visual Studio Team Services and then deploy using Continuous delivery Works.
Use Case 2: When trying to publish directly using Visual Studio using App Service profile and it works.
Use Case 3: When trying to deploy through repository that is hosted at Visual Studio Team Services. And it fails and thats the error.
Any lead will be helpful.
Do let me know, if the information provided is not enough.
To compile C# 7.0 code, we need msbuild 15 installed. Currently, msbuild15 is not enabled on Azure Web App.
For Use Case 1 and 2, the C#(7.0) code is build on your development side on which
Visual Studio 2017(msbuild 15) is installed.
For Use Case 3, the code will be complied on Azure Web App, so it will throw errors.
Microsoft engineers are in the process of building these tools for Azure, they should be out soon. you could stay updated on github

Web Deployment tools for Visual Studio 2013

I am responsible for supporting a relatively complex Website project written with .NET 3.5.
Previously I was using Web Deployment Project with Visual Studio 2010 to deploy this website but at the moment I have only access to Visual Studio 2013.
As far as I know, there is no longer such a tool to be used for deployment in Visual Studio 2013 and I do want to compile the code before deploying to the production server. As mentioned earlier, the project is a bit complex and this would not be easy to be converted to a Web Application.
Any idea?
Unless I missed it, unsure what the issue is - in VS2013, Publish is what you are looking for (either WebSite or Application).
What exactly do you mean by "none of the (vs 2013 publish) options worked"? What is/was the issue?
In one of your comments, you state you want to "pre-compile" (aka "don't want to upload .cs source files) and that's a setting in Publish.
You can Publish to your local file system: "Custom" -> File System:
This extension still exists for Visual Studio 2013: http://www.iis.net/downloads/microsoft/web-deploy
Little bit confused with the question because you are keep referring about website rather web application.
If you are looking to convert web site to web app then you need to follow this: http://msdn.microsoft.com/en-us/library/vstudio/aa983476(v=vs.100).aspx
Otherwise, if you are referring about the deployment project. Yes, it is no longer available.
I'd a very similar situation like you and Since 2013 I have stopped using any deployment project, instead I have started using Publish that creates a deployment package for you on a Network , FTP, Local Drive or even on Azure.
Here is a nice guide from Microsoft
http://msdn.microsoft.com/en-us/library/dd465323(v=vs.110).aspx
If you still want to go for Deployment Project, then you would need to go for "Installshield" limited edition,which is free (http://samirvaidya.blogspot.com.au/2013/11/how-to-enable-installshield-le-for.html).
http://msdn.microsoft.com/en-us/library/2kt85ked(v=vs.110).aspx

asp.net, a web site project cant run dlls of 64 bit

I encountered a problem.
Now, I'm using Visual Studio 2010 to create a web site project (It's not web app.), I need to add a .dll file built under 64 bit platform by visual studio to this project, when I tried to build this project, I occurred an error says:
Could not load file or assembly 'XXXXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I tried many methods to solve this error, but they all don't work ?
I'm working with this dll at the moment on local host with VS 2008, to get the dll to work I had to place it in C:\Windows\system and it runs fine. But I am worried about transferring it to my web server, though I'll cross that bridge once I've got the app working. Hope this helps

Resources