Problem with MvcContrib - asp.net-mvc

I want to use MvcContrib Grid helper, but i stuck on the problem - it's not working.
I downloaded release for mvc 1, i have dll on my hard drive, i added a reference to my project, but i always getting following error:
Error 1 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'Grid' and no extension method 'Grid' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
I am using Visual Web Developer 2008 if this is important
The question is: how correctly add this to my project?
Can you give me step by step instruction?
Thanks

Have you add the namespace in your web.config ?
<pages>
<namespaces>
...
<add namespace="MvcContrib.UI"/>
<add namespace="MvcContrib.UI.Html"/>
<add namespace="MvcContrib"/>
</namespaces>
...
</pages>

I don't think you have the reference to the MVcContrib dll added. See my sample app here:
http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx
Note that a reference has been added in the solution to the dll.

Related

referencing a f# fsharp libary in blazor

I am trying to reference a F# project(Class Library) in Blazor.
I add this to the Blazor.csproj and it compiles.
<ItemGroup>
<ProjectReference Include="FSharpLibrary\FSharpLibrary.fsproj" />
Great.
But when I add it to _Imports.razor I get the error message :
The type or namespace name 'FSharpLibrary' could not be found (are you missing a using directive or an assembly reference?)
Am I missing something or is this just not possible in Blazor?

Error with NinjectValidatorFactory after updating FluentValidation with Nuget

I have the following line of code in my NinjectModule:
Bind<IValidatorFactory>().To<NinjectValidatorFactory>().InSingletonScope();
This used to work fine, but after doing a bunch of updates with Nuget, I'm getting the following errors:
Error 3 The type 'Ninject.Web.Mvc.FluentValidation.NinjectValidatorFactory' cannot be used as type parameter 'TImplementation' in the generic type or method 'Ninject.Syntax.IBindingToSyntax.To()'. There is no implicit reference conversion from 'Ninject.Web.Mvc.FluentValidation.NinjectValidatorFactory' to 'FluentValidation.IValidatorFactory'. D:\Projects\Current...\Configuration\MainModule.cs 19 13
Error 4 The type 'FluentValidation.ValidatorFactoryBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'FluentValidation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a82054b837897c66'. D:\Projects\Current...\Configuration\MainModule.cs 19 13
It's true that I don't have a reference to FluentValidation Version=2.0.0.0, but I do have a reference to FluentValidation Version=3.4.0.0.
According to the metadata...
IValidatorFactory and ValidatorFactoryBase are defined in Assembly FluentValidation.dll.
NinjectValidatorFactory is defined in Assembly Ninject.Web.Mvc.FluentValidation.dll.
In my References folder, I have FluentValidation v3.4.0.0 and Ninject.Web.Mvc.FluentValidation v3.0.0.0.
I don't get why the compiler thinks I need FluentValidation Version=2.0.0.0.
Am I doing something wrong, or is this an issue with the Nuget package?
It looks as if the problem is that FluentValidation used to be a signed assembly but is now an unsigned assembly. Ninject.Web.Mvc.FluentValidation, however, still thinks FluentValidation is signed.
If you look at these two assemblies in ILSpy, you will notice the following:
Ninject.Web.Mvc.FluentValidation references FluentValidation with the following attributes: FluentValidation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a82054b837897c66
The latest version of FluentValidation, however, has different attributes: FluentValidation, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null
Note that PublicKeyToken has changed to null (unsigned).
Hopefully, there will be a fix to this soon. Meanwhile, the options are to roll back to the previous FluentValidation or fix the reference via a new fork.
Update
Just posted a bug report to Ninject.Web.Mvc.FluentValidation. Hopefully, this will ensure that the issue is resolved quickly.
Update 2
Just in case anyone missed it, the comment from #dismissile below contains a good solution. I gave it a try and it pretty much works. Here's a slight variation with more detail:
Remove all Nuget packages that contain "FluentValidation".
Use Nuget to install FluentValidation-Signed.
Use Nuget to install FluentValidation.MVC3-Signed (or MVC4-Signed)
Using Package Manager Console, enter the following:
Install-Package Ninject.Web.Mvc.FluentValidation -IgnoreDependencies
Note: I didn't need to manually add a binding redirect to my Web.config (although the Nuget package added one automatically).
The problem is correctly identified by DanM. Here is the comment from the project coordinator
"Going forward the primary nuget package will no longer be strongly named.
A separate package, FluentValidation-signed can be used if you absoloutely need strong naming, but it is recommended that you use the unsigned version." Jeremy Skinner

MVC "Add Controller" is "Unable to Retrieve Metadata...Config System Failed to Initialize"

From scratch, I made a new solution with two projects: one was MVC 3 and the other a supporting EF 4.2 project. The whole thing builds successfully. From the MVC project I open the "Add Controller" dialogue and have it generate code based on the context and model I select from the supporting EF project. The "add controller" dialogue fails with the message:
Unable to retrieve metadata for 'MyModelClass'. Configuration system failed to initialize.
I've noticed that the "add controller" dialogue is actually attempting to fetch the database connection string from its web.config file. First, this strikes me as goofy-ish, since the supporting EF project already has an app.config with the connection string. But never-minding that, the best I can figure is that the connection string in the web.config is bad somehow. This is what it looks like:
<add name="Monsters2Entities"
connectionString="
metadata=res://*/Monsters.csdl|
res://*/Monsters.ssdl|
res://*/Monsters.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=.;
initial catalog=Monsters2;
integrated security=True;
pooling=False;
multipleactiveresultsets=True;
App=EntityFramework
""
providerName="System.Data.EntityClient"
/>
The connection string doesn't actually have all the ridiculous line breaks and indentation - I'm just trying to make it easier to read. Anyway, that connection string is basically identical to the connection string used in the supporting EF project upon which it is modelled. How do I correct the situation, to make the "add controller" dialgoue happy?
I had installed EF 6 which added:
<providers>
<provider invariantName="System.Data.SqlClient"
type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
In my config file. I had other scaffolding issues and so decided to fall back to Ef 5. After uninstalling EF 6 and reinstalling EF 5 I deleted the from the config and then I was able to build my new controller. I discovered this by using the
PM> Update-Database –Verbose
Just copy the connection string information from your EF model project App.Config into your and watch that you do not repeat any sections (entityFramework section for example)
Try this:
<add name="Monsters2Entities"
connectionString="
metadata=res://*/Monsters.csdl|
res://*/Monsters.ssdl|
res://*/Monsters.msl;
provider=System.Data.SqlClient;
provider connection string='
data source=.;
initial catalog=Monsters2;
integrated security=True;
pooling=False;
multipleactiveresultsets=True;
App=EntityFramework
'"
providerName="System.Data.EntityClient"
/>
I have replaced " with '
I added this to my Global.Asax file so that a) the database was started immediately and b) the table definition was added. allowing the Controller to find the table definition:
System.Data.Entity.Database.SetInitializer<ProjectName.DAL.DBConnectContextName>(new CreateDatabaseIfNotExists<ProjectName.DAL.DBConnectContextName>());
I found thjis helped when I had this problem:
Uninstalled the pre-release version of EF and installed EF5
Went to Sql Server Object Explorer and deleted the db.
Rebuilt the solution
used PM> Update-Database -Verbose
Perhaps the problem was with pre-release EF or just cleansing the palate was all it needed.
I'm quite new to all of these but this did let me use the Add Controller scaffolding tool with the "MVC controller with read/write actions and reviews, using Entity Framework" template selected.
First of all you should check your connection string must be in your Web.Config file in the ROOT! of your project after that check if there is another connection string or not if there is another connection string replace it with your connection string....
This solved my problem which was same as your's....
I managed to solve my problem by changing the edmx's code generation strategy to T4, adding a EF5 Db Context and replacing %edmxInputFile% in both the *.tt and *.Context.tt files.
Rename the Model class - worked for me
Are you sure to have a ConnectionString in your Web.Config file before to create a Controller ? Sometimes we create another project which contains the Entity DB Context and we forgot to add this same connectionString in the Web.Config inside the another project.
<connectionStrings>
<add name="Monsters2Entities" ... />
</connectionStrings>
I face this issue "Unable to retrieve metadata..." while I was dding a Controller.
Solution for this is as follows.
In Connection String change provider to "system.data.sqlclient"
2.or Remove the Connection String from the Web.config and Add controller and after adding controller again add the connection String.
It seems this is a bug in MVC.
I hope with this you can go ahead.
first need to install package entity framework
go to tool>
Libray package manager> pakage manager console > :install entity framework

FSharp.Core.sigdata not found alongside FSharp.Core

I'm trying to use F# for an ASP.NET MVC application. One my controller actions sends an F# list to the view, so I write:
<%# Page Language="C#" Inherits="ViewPage<FSharpList<int>>" %>
Of course, for this to work, I have to add Microsoft.FSharp.Collections to the namespaces element in my web.config:
<add namespace="Microsoft.FSharp.Collections"/>
and add a reference to FSharp.Core, in the assemblies element:
<add assembly="FSharp.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
As soon as I add this assembly reference, every view (whether it uses an F# type or not) fails with this error:
error FS1221: FSharp.Core.sigdata not found alongside FSharp.Core
I can work around this by not having any F# specific types in my views, but what's the reason for this error? Also, where's FSharp.Core.sigdata ? It's not in my GAC and I can't find it anywhere.
You'll find it with the Reference Assemblies, as sigdata and optdata are design-time things (but I guess CodeDom needs them too?), e.g.:
C:\Program Files\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0\FSharp.Core.dll
C:\Program Files\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0\FSharp.Core.optdata
C:\Program Files\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0\FSharp.Core.sigdata
If you copy those next to the FSharp.Core that the app is using, it will probably work.

Spark View Engine "An assembly with the same simple name" error

I am trying out the Spark view engine with ASP MVC but get the error below when displaying a view. The view references model objects that are in a different assembly to the main web application (MyApp.Model.dll). I am stuck on the cause or resolution to this.
Dynamic view compilation failed.
0,0): error CS1704: An assembly with the same simple name
'MyApp.Model, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null has already been imported. Try removing one of the
references or sign them to enable side-by-side.
It sounds like you're referencing the same assembly multiple times in your view. Instead of using the <use assembly=""> element you might want to use the <use namesace=""> element
Craig I got the same problem, if I modify some class in assembly X and do a build, I got this error at runtime for the assembly X.
But after a "rebuild" (not "build") it's working.
For me it has been in the middle of a project. It comes maybe from an update ?
Matthieu

Resources