Last post Apr 07, 2021 06:01 PM by coreysan
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-220.127.116.11" newVersion="18.104.22.168" />
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.