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.
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'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.
I'm in C# land today. I'm trying to write a function which accepts a user agent string and returns an object that gives me at least the browser name and version. So I tried this answer, but apparently I don't have access to HttpBrowserCapabilities. It tells me the type or namespace name could not be found (yes, even if I add using System.Web, it still doesn't show up, or when I type using System.Web. it doesn't pop up, so it's obviously not there).
I'm using .net 3.5, but the documentation for that class shows it existed even in 3.5, so I'm not sure what's going on. I have access to the browscap files - ini or xml. Am I going to have to write this from scratch?
Edit: I've fixed the reference problem. But Chrome is being reported as AppleMAC-Safari 5.0. I'm wondering if I'm going to need a completely different approach. PHP figures it out with the same ini file fine.
Adding a using block does not automatically import the DLL. All a using does is allow you to not write:
System.Web.HttpClient //Or whatever
All over the place, and use HttpClient instead.
You need to add a reference to System.Web to the project before any of its classes will be available to you.
Did you have a using System.Web; statement in your source file?
Here's a tip: if you're using Visual Studio, and you have a reference to the System.Web.dll in your project, if you type the name of a type and press Ctrl-. it will give you a popup menu to add the namespace reference to your source file.
Do you see it in the ObjectBrowser (assuming you are using Visual Studio)? I found the namespace this morning (granted I'm on 4.5 - but documentation shows it has been around since 3.5 and earlier)
In C#, I made a ClassLibrary that has one Namespace and one Class.
I saved it and build it.
in other Projects, when i use it, I add it to my references by browsing to the .dll location.
But The Problem is that its name is not showing up in the Intellisense.
i.e when I: using ... my dll doesn't show ..
I'm Importing the library to a ConsoleApp.
both of the App and the library target Framework is .NET Framework 4.0
and I made their Assembly Version 4.0.0.0 so they're the exact same.
is there a setting or something that I'm missing ?
how can i make it pop up ?
I'm using VS2010 Professional
Thank you for your help
Maybe this be usefull, I was having a similar issue, I have a Web project, add the reference to a Class Library by selecting the project, but if I made a change on the class library, I canĀ“t see that change on the intellisense of the Web Project, after try many things, I see that in the recently added reference, the value of the option "Local Copy" was set "True", then I change it to false and everething works!
I had a similar issue but in my case it was a property on the class. If you go to the file properties and look for a Build Action. Somehow mine was set to Content it had to be set to Compile.
I am using Visual Studio 2013. I hope this helps someone else.
Is the namespace for your assembly different than the namespace for your currently open project? I've had times when the current project and an assembly share the same namespace path the intellisense can mess up.
In general, Visual Studio is pretty good about intellisense generation, especially for C#. But sometimes there are some interesting conditions regarding ambiguities, and especially mixing project types where it just doesn't quite work.
Placing your content in the same namespace makes me wonder if you've actually fixed the problem (it may just be autocompleting the namespace in the currently loaded project rather than the assembly), but if it allows you to continue working, then go with it!
Right click on project on which you add reference of your dll/project select menu project dependancies and select/MarkCheckBox for reference project/dll. then it will work fine.
If the class library project had its name changed after creation, then intellisense may fail finding it due to directory issues, I believe.
I created my class with the generic "ClassLibrary1" or whatever, and then later changed the default namespace, class name, and project name inside of VS2017. I closed VS2017 and changed the directory name to match my default namespace, and then re-associated the project file in VS2017, and then re-added the reference in my main project file.
All seems to be fixed now.
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