Can't get Webmatrix.WebData for Simple Membership referenced in MVC5? - c#

I'm trying to use Simple Membership in an MVC 5 project. I followed a video tutorial on a test project on my machine and was able to get it to work. Now I'm ready to implement it on a new website but when I get to the step of making a reference for Webmatrix.Data and Webmatrix.WebData I don't have the option in the References/Assemblies/Extensions section. I went to NuGet and tried to add WebMatrix and saw where is said it was legacy and to use AspNet.WebPages.WebData which I then installed through NuGet. Still no reference available for Webmatrix.
So, I looked at the references of the project that was working and found that there was a Packages/Microsoft.AspNet.WebPages.WebData.3.2.3 folder and copied that to my current projects folder. I then made a manual reference to the WebMatrix.dll in that folder and made sure that it was listed in my packages.config file like my working project. That seemed to have fixed my issue where it my pages were referencing the System.Web.Security.
However, in my Global.asax page I need to have the following
WebSecurity.InitializeDatabaseConnection("DbConnection", "Users", "UserId", "UserName", autoCreateTables: true);
I'm getting an error with that. It says 'object' does not contain a definition for 'InitializeDatabaseConnection and the using WebMatrix.WebData is grayed out at the top. When I type WebSecurity and look at the options through intellisense I have very few options and InitializeDatabaseConnection is definitely not there. I can see the reference to WebMatrix.Data and WebMatrix.WebData listed in my References section and there doesn't seem to be any errors associated with that.
I've tried to do some Google searches and can't find anything about the issue. I've been at this for several hours and I'm pulling my hair out trying to get this to work. Please, any suggests would be really helpful...I'm at a complete loss.

I had NuGet install Microsoft.AspNet.WebPages.WebData, Microsoft.AspNet.WebPages.Data and Microsoft.AspNet.WebPages (all v3.2.4).
Then I added a reference to WebMatrix.WebData by browsing to the package (.....\packages\Microsoft.AspNet.WebPages.WebData.3.2.4\lib\net45\WebMatrix.WebData.dll).
And everything worked fine, with
using System.Web.Security;
using WebMatrix.WebData;

Related

Reference seemingly not working, no apparent error thrown

I have superficial knowledge on referencing libraries in projects. Usually most of the time a simple 'add reference' and then browsing to the appropriate path, just works. I am following an issue I will try to explain , and show all the approaches I tried to tackle it.
I am trying to use AutoIt. In their website it is stated that simply adding the .dll and using it, is enough to integrate their functionality in visual studio.
I am doing just that but for the moment I can not get my head around what is happening.
AutoItX is a public static class, as also the Run function is the same (public static). After adding the reference I can navigate to the appropriate .cs (if I control click on it for example). So the class AutoItX is not something unknown for the project. Moreover, the function Run indeed exists
however not inside the project itself. AutoItX also needs staff from (dont know if it is important):
The main error is that AutoItX doesnt exist in this context.
I have tried to register the dll, I have tried to add the com reference and remove it, I have tried to move the .cs files inside the project. None of those corrected the issue.
Any help would be valuable. If I missed something and you need extra info, I am willing to provide it. (Latest vs, latest autoit version, .net framework type of project).
Actually the above works.
For future reference.
The reason I did not try it first was, that they propose in their website to reference the autoItX.assembly.dll. This is probably deprecated and does NOT work anymore.
Second, if you have already referenced it , downloading this from NuGet WONT fix it.
Finally, the NuGet package does NOT work with .net CORE but ONLY with .net Framework project
I installed AutoItX.Dotnet 3.3.14.5, my test is no problem.
You can refer to my steps to create a new project to test it.
Right click References=>Manage NuGet Packages=>Browse=>AutoItX.Dotnet=>Install
Running result:

Problem displaying MVC webgrid in a webform project

I have added MVC files/folders to an existing Webforms project. In the References, i have added the reference to 'System.Web.Helpers.dll'.
Now, while trying to display the Webgrid, i am getting the following message:
Message=Inheritance security rules violated by type: 'System.Web.Helpers.WebGridRenderer'. Derived types must either match the security accessibility of the base type or be less accessible.
Source=System.Web.Helpers.
Most of the fixes that i have seen so far for this kind of error state the following solutions, and i have already tried all of them:
No Security tab in the properties of the my project, so unchecking "Enable ClickOnce Security Settings" is not an option.
Have tried to comment out the reference to 'System.Web.Helpers' in the web.config.
The following line already does not exist in my AssemblyInfo.cs file, so removing this line is also not an option. [assembly: System.Security.AllowPartiallyTrustedCallers]
Looks like the problem is because, i have added MVC files in a Webforms project, but am wondering if there is any fix for this problem?
Thanks.
After i updated my System.Web.Helpers.dll to version 3.0.0.0 and also copied its xml file in the reference folder, it's working for me now.

The type or namespace name 'Membership' does not exist in the namespace 'Microsoft.AspNet'

I'm trying to maintain an application that contains the following line in several different files:
using Microsoft.AspNet.Membership.OpenAuth;
I've tried everything I could find. Removed and re-added the reference; cleared the MEF cache and rebuilt; added a different file as a reference. Nothing works. It's bizarre because VS2017 doesn't report this error in the Error List window, but it does show up in the Output window. Anyway, can someone please suggest a possible solution that maybe I haven't tried yet? Thanks.
I was able to compile the project and I will describe how I got it.
1 - I delete all using Microsoft.AspNet.Membership.OpenAuth; and build project.
2 - After build the code show many errors I use the resource of VS2015 help fixes errors on code Show potential fixes and set again using Microsoft.AspNet.Membership.OpenAuth; build project.
3 - Set a new framework 4.6 and build project.
https://drive.google.com/open?id=0B4aywYtmwk6lT1dDNnIxRmtQcUk

CS0012 Error when building the getting started Xamarin Android app

I am following along with the getting started tutorial:
https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-dotnet-backend-xamarin-android-get-started-preview/
I can successfully work the steps up through "Publish your server project to Azure". However, when I download, open and build the Xamarin.Android app I have issues. Specifically, the output window says the build was successful, but the error window indicates that there are 14 errors, all of which are CS0012.
I understand that the "System.Runtime" assembly isn't being referenced, but no solutions I have been able to identify on MSDN or on StackExchange seem to correct the issue.
Any help would be appreciated!
I was able to solve this issue, plus a number of others (related to missing references) by adding the references using the "server" portion of the getting started demo. I also had to update all of the nugget packages as the references I added were in conflict with some of the existing references in the project.

How do I reference Route and ResponseType Attributes?

My computer unexpectedly crashed while I was working in visual studio on a web application. As a result my csproj was completely corrupted, so I had to start a new web project and re-add all the files and assemblies from my old project.
But for some reason Route, which should be in System.Web.Http, and ResponseType, which should be in System.Web.Http.Description cannot be found, even though I still have the appropriate usings for them. Also, my project is still referencing System.Web and System.Web.Http, and all the other stuff in my application seems to not be generating any errors like this at the moment.
I've also tried writing out the full path to these classes (i.e. System.Web.Http.Description.ResponseType) but while intellisense is able to explore the namespace, the Route and ResponseType attributes are missing.
I'm not sure if this is related, but when I right-click on Controllers and select Add, I don't get an option to add a controller any more. Something got really messed up with this project...
You should re-install the necessary packages to enable Attribute Routing.
From the Tools menu in Visual Studio, select Library Package Manager, then select Package Manager Console. Enter the following command in the Package Manager Console window:
Install-Package Microsoft.AspNet.WebApi.WebHost
Then after manually adding relevant references (i.e System.Web.dll and System.Web.Http.dll if they aren't already referenced) and using proper namespaces, your attributes should work:
using System;
using System.Web.Http;
using System.Web.Http.Description;
As an alternative to the accepted answer, I found that it was possible to automatically have the necessary packages installed as soon as the first Web API 2 controller is added to the project through the solution explorer's context menu.
Resolve for me by doing the following!
Save the solution
update-package -reinstall

Categories

Resources