Last post Apr 13, 2021 08:55 PM by PatriceSc
Apr 05, 2021 11:59 PM|coreysan|LINK
I wrote a website in aspx, using Visual Studio. I downloaded a few packages to get the NewtonSoft library, and other DLLs for tokens. My project uses JsonArrays a lot.
The DLLs are in "bin", and in my codebehind file I have references like this: "Using NewtonSoft.Json;" for example.
But when I deploy all the files to an IIS environment, I get Error CS0246, can't find the NewtonSoft library and others. My project runs well except for this one issue - not finding 3rd party DLLs.
I've read a lot of Stackoverflow articles, but they mostly talk about setting paths in VS. But once I deploy, there's no VS. So I'm not understanding something maybe.
If my Default.asps.cs file has "Using Newtonsoft.Json" and my directory has a fully populated "bin" folder, then why can't it find the DLLs?
Apr 06, 2021 03:38 AM|Sean Fang|LINK
The error tells that you don't output the library to the target bin folder.
I think we need to target the problem first. Have you checked if the target
bin folder contains the 'NewtonSoft.Json' assemby or not? (Open the
bin folder under the publish folder)
Before that, could you please tell me the steps that you add the
NewtonSoft library in your project?
The common way that we add references in VS is to right click the "References" section in
Solution Explorer and add the assembly. Moreover, you need to make sure that the "Copy Local" is set to "True".
Apr 06, 2021 04:10 PM|coreysan|LINK
Sean, I appreciate your input - thank you! This is my first time deploying a VS project to an IIS server, so I realize I have much to learn. But here goes:
top-level directory/myapp (not the real name, but you get the idea)
top-level directory/myapp/Default.aspx and Default.aspx.cs
The top-level index.html has a link to:
Inside the Default.aspx.cs file, I have references like this: "using Newtonsoft.Json;"
I don't know why running the app doesn't see the DLLs in the bin directory. That's my core problem. Do these DLLs need to be registered somehow? I know that some articles on StackOverflow talk about gacutil.exe, but I've never used that program before.
I'm sure I'm missing an important step, but I have no idea what it is!
Apr 07, 2021 06:42 AM|Sean Fang|LINK
Thank you very much for detailed information.
I don't think you miss steps based on your description. By the way, what is the
exact error message? Is it for namespace or
According to this documentation:
Compiler Error CS0246, the error could be various for different situations.
Here we can adopt some solutions to narrow down the problem.
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-18.104.22.168" newVersion="22.214.171.124" />
Apr 07, 2021 07:39 AM|PatriceSc|LINK
myapp was added as a new *application* as well? Could it be that IIS looks at
top-level directory/bin rather than to top-level directory/myapp/bin ?
Apr 07, 2021 04:58 PM|coreysan|LINK
Again - thank you so much for your assistance. I'm more than grateful!
I do have the reference to BindingRedirect in the Web.Config file. But before I go any further, I learned something from the other reply by PatriceSC. I got much better behavior when I moved the "bin" folder up one level. It resolved the NewtonSoft message!
Now it says it can't find the System.Het.http assembly. So I'll see if I can add that and see what happens!
Apr 07, 2021 05:09 PM|coreysan|LINK
PatriceSc, I mentioned to Sean that I had the "bin" folder down a level. When I moved it up one level as you suggested, I got much better behavior. So your suggestion might be the very fix I need.
I need to also add the "System.Net.http" assembly as well. I'll test some more before I conclude this thread.
Thank you for your suggestion! So simple!
Apr 07, 2021 06:01 PM|coreysan|LINK
Spot on! That was it. I didn't know that "bin" had a default location.
Is there any way to tell IIS that for this app, the bin folder has been moved elsewhere? I can leave "bin" where it is, but I'd like to move it if possible. I've tried several different ways in the web.config, but I haven't figured it out yet.
Apr 13, 2021 05:44 AM|Sean Fang|LINK
Have you tried to use below element?
<assemblyBinding> Element for <runtime>
Under this element, there is an element called:
It specifies application base subdirectories for the common language runtime to search when loading assemblies.
For example, you will search for assemblies from below paths one by one.
bin, bin2\subbin and bin3
Apr 13, 2021 08:35 PM|coreysan|LINK
Thanks - good to hear from you. I tried using probing PrivatePAth as you recommended, but without success!
Right now I'm using the bin folder at the top level to get it working, but someday it would be nice to point to a subfolder location.
Apr 13, 2021 08:55 PM|PatriceSc|LINK
It was just to understand what happens but not how I would suggest to fix that. More likely tou just added folders and so you actually have a single application.
Instead you can use
https://www.helpmasterpro.com/helpfile/Web%20Modules/html%20files/Virtual%20Directory%20-%20creating%20in%20iis7.htm so that those new folders are actually REAL web applicaitons on their own. If the app is well written, it should work quite well. At worst
you'll may need to fix links so that they are relative to the root of the web app rather than to the root of the web site.
Edit for example you can have folders such as c:\main, c::\app1, c:\app2, c:\app3 where each app in its own folder.
The site points to the c:\main folder which is basically and empty app. You can use the link above to create new applications pointing each to its own folder.
As a result you have a http://main.com site and then you have http:://main.com/app1,
http://main.com/aoo2 etc.. each being a separate web application.