I am getting issue "Unable to load DLL ‘PDFNetC’ or one of its dependencies" when running pdftron .net core in windows docker container.
Where should I add the “PDFNetC.dll” in container to make this work. I have added it at all the possible locations but not working
Related
I've created a .net core web api project and am successfully running it under Docker Desktop for Window. It works fine as long as I'm running the project in Visual Studio. I run the "Docker" profile and hit it with localhost:8000/. I've configured it to use port 8000...
But when I stop the visual studio debugger, I can no longer access it even though when it still shows up as "RUNNING" in Docker Desktop. How can I access the service in the container, without running the project in Visual Studio?
I'm a newbie in this area, but if an image has been built and that image is running in a container, I'd think I'd be able to access it without needing to run the visual studio project. Isn't the container a "compiled, built, stood-up instance of my image, running in a docker host"???
Thanks, Brent
"Isn't the container a "compiled, built, stood-up instance of my image, running in a docker host"???" Yes, it is, you're 100% right, but in the Visual Studio, they made some performance adjustments so everything can run so smoothly, without any overhead of stopping and removing the container, updating the image and running it etc. In fact, under the hood, your binaries and source code are mapped via volume, so there's no need to juggle building new images etc. every time you run the app. If you run docker inspect on the container created by the Visual Studio, you'll be able to see that that mapping in the "Mounts" section of the JSON output.
I created a brand new ASP.NET Core web API app from the template with Docker enabled. I noticed that the container lifetime is linked with the Visual Studio process. If I close the Visual Studio the container is stopped and removed and as soon as I open the solution with the previously mentioned project in the Visual Studio the container is immediately up and running even though I haven't even started debugging yet.
If you want to run a container outside of the Visual Studio, you can always build the image from the Dockerfile in your project and run it.
It could look like this:
cd "path/with/your/Dockerfile"
docker build -t "your-image-name" .
docker run -it -p 8000:80 -n "your-container-name" "your-image-name"
I have a .NET core application that uses the library of PortSip. So far everything worked fine both locally in my Windows 10 laptop and in an EC2 AWS instance with Windows Server 2019 installed, and now I would like to make this work in a Docker container.
So I used a Dockerfile similar to what's mentioned it this link https://schwabencode.com/blog/2018/08/30/ASP-NET-Core-with-NET-Framework-on-Docker to have a Windows Server Core image with both .NET framework (what PortSip needs) and .NET core (what my app needs) as well as added commands to install C++ Redistributable.
The result is that I'm getting the following error when trying to run my app:
Unhandled exception. System.DllNotFoundException: Unable to load DLL 'portsip_sdk.dll' or one of its dependencies: The specified module could not be
found. (0x8007007E)
The DLLs are there! In addition, when I change them to PortSip's 32-bit DLLs, the error changes to "An attempt was made to load a program with an incorrect format". That means the existence of the DLL is felt, but still, for some reason, cannot be loaded.
Also worth mentioning that with the exact same installations (the .NETs and the C++ redistributable) in a blank EC2 as mentioned above the app works.
What am I missing?
Thanks in adavance
Solved by copying two DLLs, C:\Windows\System32\edputil.dll and C:\Windows\System32\msdmo.dll from my local machine to that docker image.
I'm trying to put a .NET Core 3.1 application listing users in an AD group into a .NET Core Runtime Docker container.
Accessing the AD is being done with the help of a DirectorySearcher from the System.DirectoryServices namespace.
Out of the box, .NET Core doesn't support this namespace, but by adding the package System.DirectoryServices (dotnet add package System.DirectoryServices) installed the required assemblies and the application runs fine on a Win10 machine.
Trying to let the app run in a Linux .Net Core Runtime container throws an exception because DirectoryServices doesn't support this platform.
So I tried using a Windows-based container (tag 3.1.8-nanoserver-2004 to be precise), but then the DirectorySearcher's FindAll() throws the exception
System.DllNotFoundException: Unable to load DLL 'activeds.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
I've even tried copying the DLL from my host machine into the application's bin directory in the container, but to no avail.
Anyone got an idea what to do to access AD/LDAP from a container?
Since I could not get a Windows Server container to add the Active Directory feature for the life of me, I decided to switch to something different and found LdapForNet
While this works nicely on the dev machine, I also had a hard time finding a way to call the required Bind() to our domain controller from inside a container.
But after half a day of trial and error I found that LdapAuthType.Negotiate worked, but only if I gave the Realm as well:
using (var conn = new LdapConnection()){
conn.Connect(new Uri("LDAP://the.domain.controller"));
conn.Bind(LdapForNet.Native.Native.LdapAuthType.Negotiate,
new LdapCredential {
Realm = "DC=thedomain,DC=com",
UserName = "The user to authenticate",
Password = "Plain text password"
}
);
}
Hope this helps others trying to get LDAP queries running inside a container.
Next stop: Trying the same inside a Linux container.
DirectoryServices will not currently work in Nano Server because the required dependencies are not available. You'll need to use a Windows Server Core image instead. There are not official .NET Core images available for Windows Server Core. (At least not yet. When .NET 5.0 ships, Windows Server Core images will be available for it. See GitHub issue for that proposal.)
You'll need to define your own Dockerfile that uses Windows Server Core as a base image and installs .NET Core in it. There is guidance on how to do this here.
Related links:
Using System.DirectoryServices on a Windows container with ASP.NET Core returns an error
DirectoryServices deployement on nano serve Unable to load activeds.dll
I am working on .Net core Microservices. I installed Docker Toolbox containing docker cli and kitematics. After that i created a simple (.Net core) web api project in visual studio 2017 and also enable docker support.
But when i hit F5 to run the program it shows following error and doesn't run.
Visual Studio Container Tools requires Docker to be running before building, debugging or running a containerized project.
Please review the attached image.
Visual studio error on running the project
If i build and run the project using docker cli, it's working. The problem is with visual studio 2017.
In my case I had an erroneous reference in Dependencies > Packages to Microsoft.VisualStudio.Azure.Containers.Tools.Targets
Removing the reference fixed the error.
The problem occurs because Visual studio container is unable to connect to docker for windows and solution for this is to open the visual studio 2017 from Docker CLI using following command.
/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/Community/Common7/IDE/devenv.exe C:\\PATH\\TO\\MY\\SOLUTION.sln
Here:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe
is the location of my devenv.exe file and 2nd parameter
C:\\PATH\\TO\\MY\\SOLUTION.sln
shows the path of solution file.
For further details of this solution, click Here.
In my case, this issue was caused by a disabled BIOS Virtualization. To enable Virtualization, see here. In order to check whether Virtualization is already enabled, start Task Manager > Performance > find Virtualization. If you are hosting your docker container application in full feature IIS, make sure you start Visual Studio as an Administrator.
I was getting the same error when I was trying to rebuild my solution after changing my .Net Core 2.0 application to .Net Core 2.2. As I reset my windows, there was no docker installed on my machine. To fix this all I had to do is to install the docker for desktop as I wanted to containerize my applications.
Once you install the Docker, it will ask you to enable Hyper-V and Container features. By clicking the Ok button in the pop up as preceding, will enable this features for you.
Your computer will be restarted automatically and once it is done, you should be able to see that the Virtualization is enabled in the task bar.
After this I was not facing this error.
Check shared folders inside the default virtual machine setting in Virtual box to make sure you shared the disk where you project located. By default shared only C:\Users. So alternatively you can move your project somewhere inside C:\Users folder (for example in Desktop folder)
I was facing the same issue and I resolved it by switching to IIS Express instead of Docker in debug menue on visual studio 2017
Can I package up a .Net web application (that normally runs on Windows 7 etc) to run in a Docker container, and then execute it on 'any' host supporting Docker?
Such as Dockers on Linux or Dockers on Windows etc?
You can at least use dotnet core image.
From Getting Started with .NET and Docker:
.NET Core is the open-source version of .NET which is available now. It has a different focus from the full .NET and it’s a modular framework, so you only include the parts you need – the framework itself is composed from NuGet packages.
Before you can run .NET Core apps on a Linux (or OS/X, or Windows) machine, you need to install the DNX runtime. This isn’t the full .NET runtime that we have on Windows; it’s a slimmed-down .NET Execution Environment (DNX).
When you define a Docker image, you start from an existing base image, and the sixeyed/coreclr-base image which is publically available on the Hub already has the DNX installed and configured. To containerize your own .NET Core app, just use that base image and add in your own code.