I am having trouble using the NATUPnPLib. I have a piece of code that works perfectly fine while the project is running on .Net 4. But, unfortunately when I try the same piece of code in .Net3.5, I get some assembly reference errors while building the project.
UPnPNATClass upnpnat = new UPnPNATClass();
IStaticPortMappingCollection mappings = upnpnat.StaticPortMappingCollection;
And i get the following build error:
The type or namespace name 'UPnPNATClass' could not be found (are you missing a using directive or an assembly reference?
Although i have added the reference to the NatUPnP Library from Add Reference --> COM
I have scoured the internet to find a solution but i was unable to find any help. I hope someone here might be able to help out.
P.S: I followed this Article about NAT Router and UPnP
Thanx & Regards.
There is no reason you should have a problem with this in 3.5, it supports this COM component well. Check list:
Make sure you added the reference and not just tried to use the interop library that your 4.0 project generated. That interop library can't be used since it has the newer metadata format
Make sure you didn't forget to add using NATUPNPLib; at the top of your source code file
As an alternative, remove the COM references and add it back with Project + Add Reference, Browse tab, select c:\windows\system32\hnetcfg.dll
My money is on the second bullet, easy to forget and easy to mis-spell.
Ran into this problem myself and I have found that when you add the reference in vs2010 with 3.5 framework settings, the interface map for the NETCONLib is transposed with the NATUPNPLib interface map, making the objects unavailable. Adding the reference in the 4.0 framework exposes the correct interface map for the to libraries so this would appear to be a fault in the tlib importer when working in 3.5.
Related
When making a project in WPF C# (.NET 5.0), I wanted to use data from my database. I have a Microsoft Access file (2000-2003 compatible version, *.mdb), which I needed to use for my project.
After I added new source
Add > new Item... > Data > DataSet and specified properly the database (the connection was tested successful), file DataSetProj.xsd has been created.
However, when I tried running the code, the following error occurred:
Error CS1069: The type name 'OleDbDataAdapter' could not be found in the namespace 'System.Data.OleDb'. This type has been forwarded to assembly 'System.Data.OleDb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly.
When clicking the CS1069 hyperlink, this site opened (unfortunately, no specifics on the error were provided).
Trying to fix the error myself, I found System.Data.OleDb namespace documentation. Here's my interesting observation: The code automatically generated by DataSetProj.Designer.cs file had classes (supposedly defined in the namespace), like OleDbConnection, or OleDbDataAdapter. Funnily enough, this namespace mentions these classes, but it appears they are not part of the namespace (although this is official MS documentation). When I enter documentation of either of the classes, they are included in the System.Data.Ole.Db namespace. This is weird and super unclear (at least for me, junior dev) documentation.
I tried switching to .NET 4.8 Framework, use EF Core Power Tools by ErikEJ (unfortunately it doesn't work with Access *.mdb file). I could not find the answer to this problem anywhere, although it seems like many people would have such an issue.
How do I make it work?
I noticed that the namespace System.Data.OleDb referenced in OleDbDataAdapter class is located in System.Data.OleDb.dll Assembly. When googled the name of the assembly, I found this link. After downloading and installing the assembly (using NuGet Package Manager), the error was resolved.
I hope that other people having the same issue will have it fixed upon visiting this post.
System.Data.OleDb is not part of .Net 5 but is available as part of the .Net Platform Extensions. See below link for more details on .Net Platform Extensions:
What are .NET Platform Extensions on learn.microsoft.com?
If ok with exclusively targeting Microsoft Windows Platform, you can consider installing the windows compatibility pack which includes the OleDb dll as well (below link) or consider rewriting your code to avoid OleDb (ODCB or ADO maybe?):
https://www.nuget.org/packages/Microsoft.Windows.Compatibility
I've created a class library in C# Visual Express 2010. I built the solution making sure that the target framework was the .NET Framework 4 and not .NET Framework 4 Client Profile.
When I try to create a Console Application and reference the library, none of my classes are recognized.
I have made sure the Console Application is also using the .NET Framework 4 and not .NET Framework 4 Client Profile
I have made sure that I am actually using the namespace of my library.
All the classes I want to access are public.
If I change my Class Library project to a Console Application project, everything works.
Restarting and/or reloading the library does not work.
After I reference my library, it appears under References, but I cannot view it in the object viewer. I'm not sure what this means
The only error messages I receive are:
Error 2 The type or namespace name could not be found (are you missing a using directive or an assembly reference?)
I'm not sure why nothing is recognized, or why I cannot use my library. Does anyone have any ideas of where I can go to look for the solution, or has anyone run into this problem themselves?
I know you have tried a lot of things here, but ultimately the following should work
In your solution make sure you have your class library and your console app (Although you don't need to have the class library in the solution, this is just for sanity sake)
Make sure they are the same framework
Make sure they both compile, take note of any errors or warnings
Add a reference to your library (remove any previous references),i.e click your console app, click Add\Reference, click solution, then check your library, click add
Add the using statement to your console app
Just to make sure everything is good , do a Clean, and rebuild
if you have done all the above and its still not working, then this seems like a benign error
I.e if everything compiles, and there are no warnings, there is really no normal reason why this shouldn't just work
All of classes that defines in class library must have -public- access modifier, unless these assemblies don't work!
I have added Class Library in my web Project through Add reference option, but i am facing an error
Error 2 The type or namespace name 'UserDetailsDll' could not be
found (are you missing a using directive or an assembly reference?)*
I hope some one will help me.
Thanks in Advance.
There are a few possibilities as to why that is happening:
You're missing a using statement. Try using the whole name of the class (namespace, then class name) you're trying to use.
Your DLL is targeting a different processor architecture. Check the properties of your web application and your DLL and see if they are both targeting the same CPU.
Your DLL is for a different .NET framework than your web application. Check the target framework in the project properties.
Finally, check the references in Visual Studio for a little yellow warning icon next to your referenced DLL. It's presence indicates that the DLL couldn't be found / referenced in the first place.
You need to either add a using in your code file or specify the full name to the class you want to use.
Both solutions can be autogenerated. Rightclick on the class that won't get resolved and click on Resolve -> using XXXX
So I am starting to learn C#, like literally just started learning, and coming from a Java background, it doesn't look too bad. However, I have a question. I am following THIS tutorial on using the client-object model. And just starting from the top, I added the references, but using Microsoft.SharePoint.Client; keeps giving me the error that "the namespace 'SharePoint' does not exist in the namespace 'Microsoft', but I clearly see it on the right side panel. So looking at the instructions, the only difference I can think of is that fact that I am using Visual Studio Express and thus do not have the option to choose which framework to use when creating a new project. Other than that, I don't know what the problem might be. Does anyone have any ideas on what else I could be missing or how to correct this problem?
Make sure that the target framework is 3.5 and not 4 i.e for SP2010
Did you add the references to the Microsoft.SharePoint.Client assembly and Microsoft.SharePoint.Client.Runtime assembly as noted near the beginning of that tutorial?
Add required references to the solution.
Make sure that the target framework is 4 for SP2013(3.5 for SP2010).
Did you do this part of the tutorial you mentioned above?
To build the application, you must add references to two assemblies,
Microsoft.SharePoint.Client.dll and
Microsoft.SharePoint.Client.Runtime.dll. Installing SharePoint
Foundation installs these assemblies on the server. The two assemblies
are located in the following directory:
%ProgramFiles%\Common Files\Microsoft Shared\web server
extensions\14\ISAPI
Take a look at the references in your project and make sure you have the reference to the assembly. If it is not there try adding it, right click -->add reference and find "Microsoft.SharePoint.Client"
Thanks to those who mentioned the 4.0 framework.
Mine defaulted to .NET Framework 4 Client Profile (and I have no idea what that means), and the Namespaces looked good in Intellisense, but the build would say they weren't found! Crazy.
for anyone developing for SP2019, you need to target .net 4.5
I recently migrated a solution from VS2005 to VS2010.
The solution is composed by about 20 project. One of them is in VB.net, the others are C#.
In VS2005 everything was fine, that is I was able to reference the VB.net project into the C Sharp projects. Now I cannot anymore.
The strange thing is that when I open in the editor a C# class referencing the VB.net dll, I get a compile error that sounds more or less like this:
"he type or namespace name 'VB.netProject' does not exist in the namespace 'Solution Namespace' (are you missing an assembly reference?)"
... and no, the assembly reference is there indeed!
However, when I close the files in the editor and try to compile again, the operation succeeds and the executable that I get works perfectly like it did in VS2005.
Is there a way I can manage to see the VB.net component in the editor? I am sure I am missing something, but I don't know what! :-)
Many thanks in advance for your help,
John
Unfortunately the visual studio sets (after the migration) the target framework to .NET Framework 4 Client Profile. If this target framework is set, some namespace could not be found (=> because the client profile doesn't contain this classes). Please verify, if your project has set this target framework. You will find this setting under the project properties.
Kind regards, patrick