I'm trying to build a UWP app that consumes a wsdl web service.
If I add a service reference to my project (as described here - http://www.c-sharpcorner.com/UploadFile/99bb20/consume-web-service-in-metro-style-app/) the service is added, but fails to build with errors:
The type or namespace name 'Web' does not exist in the namespace 'System'
I'm fairly new to UWP, is it possible that the "Web" interface is simply not present? How would I be able to tell if something is present or not in the UWP world?
You are right, there is no System.Web namespace in UWP. System.Web Namespace is a traditional .NET Framework namespace and is usually used in ASP.NET. It can't be used in UWP apps. For the .Net APIs that are supported in UWP, please see .NET for UWP apps.
However, I'm not sure why you need this namespace in your UWP app. I followed the article you've mentioned. Although there is a minor mistake, but it doesn't use System.Web namespace and it can work. So I'd suggest you check your code and find where you used the System.Web namespace.
You can also check my sample at GitHub. It works well in HoloLens Emulator.
I had a similar issue when trying to use the EWS managed API in UWP as it requires the System.Web namespace. If you can pinpoint the exact feature of the webservice you need, it is possible to re-implement the methods that require System.Web and use a similar feature in System.Net.
Obviously this is harder than just using something already built in, but you can try to find exactly what feature of System.Web you need.
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
In PresentationFramework from .NET 4.5 there is a namespace called Standard. Look here for more info: What is the namespace 'Standard'?
The problem is that in my C++/CLI project I am using an unmanaged library, which also defines a class called Standard. So I get the following compiler error:
error C2869: 'Standard' : has already been defined to be a namespace
I cannot remove the reference to PresentationFramework, and I cannot stop using the said library. Is there anything I can do? Like un-importing the namespace?
P.S. I am using VisualStudio 2012. I think that an upgrade to 2013 might help, but that will require the whole team to move to it.
That namespace was added to PresentationFramework by .NET 4.5, I believe, and I don't think changing to Visual Studio 2013 will help you. Everything in that namespace is defined as internal, and it mostly consists of Enums and Structs used with Windows SDK functions called by PresentationFramework.
Unfortunately, I have no idea what to do about your problem. Perhaps you can convince whoever supplies the third-party library to change their namespace. The fact that Microsoft is now using it would be a good reason for them to do so. Whoever these people are that are creating namespaces with a simple, generic name such as "Standard" need to have their heads examined.
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!
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
VS says, The type or namespace name 'Formatters' does not exist in the namespace 'System.Runtime.Serialization'. Well, I should add this reference. Click Project > Add reference > .NET, there I can see only System.Runtime.Serialization, nothing like Formatters.
System.Runtime.Serialization.dll appears to be under c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\ - there are no Formatters, neither Formatters.Binary there.
How to find this reference?
The BinaryFormatter is not supported in Silverlight (or Windows Phone).
So apparently Silverlight does not have the BinaryFormatter. However an open source project exists that may be able to provide similar functionality for you. It is called sharpSerializer. It will work with Silverlight and WP7.
I am keeping the other half my answer below, while not appropriate for Silverlight, may be helpful for those that are still missing said reference in other projects, as it should correct it.
For other projects that do not use Silverlight, and have access to the BinaryFormatter you may have your target framework set incorrectly.
Make sure you are using the full .NET Framework 4 Profile and not the .NET Framework 4 Client Profile in your project as your target framework. See the image below, you can find these settings in your project's properties.
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.