0

I'm newer with C# and this is going to sound absurd, but I have a special Visual Studio project type (Dynamics 365 Operations) that allows me to reference local C# projects, and DLL's, but not Nuget packages. It's a limitation of the VS project type I'm forced to use.

So I have a solution with 2 projects. The special Dynamics project (MyProj) that currently references an empty C# project (MyNewtonsoftWrapper).

In MyProj, I cannot type using Newtonsoft.Json; because I cannot use the Nuget package directly. I can do using MyNewtonsoftWrapper; and call anything I put in there.

Can I somehow pass-through everything from the Newtonsoft.Json namespace so that all of my syntax is identical if I were using the Nuget package directly?

William YK
  • 835
  • 7
  • 23
  • Nuget package is just a single or more DLLs so just take the DLL(s) and reference them instead of using Nuget package. – CodingYoshi Nov 29 '19 at 23:09
  • I can also do this, but ideally I'd like to keep the Nuget package so that I can automatically update it without manually updating the DLL each time. Effectively I'd like to alias or "whitelabel" of sorts the namespace so everything works the same. Just the `using` call has to be to my own C# project. – William YK Nov 29 '19 at 23:18
  • Makes sense. See if you can alias the wrapper as I have shown [here](https://stackoverflow.com/a/45332872/4228458) and give it the same alias as the target you're after. I have never tried it and I don't have my machine to try it. See if that works. – CodingYoshi Nov 29 '19 at 23:24
  • Could you declare Newtonsoft.Json namespace in MyNewtonsoftWrapper project? – Basil Kosovan Nov 29 '19 at 23:28
  • I can do pretty much anything in the C# project. When you say declare it...do you mean `using Newtonsoft.Json;`? I can do that. – William YK Nov 29 '19 at 23:46
  • @CodingYoshi I played around w/the alias, but I don't think that'll help. It seems like that just allows me to alias/prefix things. In my wrapper class, it seems like I need to create tons of methods that return each class from the Nuget package in order to call everything. I wish I could write in my class effectively `namespace mynamespace : Newtonsoft.Json` (like a class extension) and then leave the class entirely blank and have everything just...pass through. – William YK Nov 30 '19 at 00:13

0 Answers0