FSharp.Core.sigdata not found alongside FSharp.Core - asp.net-mvc

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.

Related

Nesper engine always tries to load types from Nesper.dll first

Every time I try to add a new type to my nesper engine, I get the following exception thrown in the nesper engine.
Could not load type 'K2Common.Order' from assembly 'NEsper, Version=4.8.0.0, Culture=neutral, PublicKeyToken=null'.
The engine eats the exception and then finds the proper type in my assembly as it iterates over each loaded assembly.
Is there a way to prevent nesper from searchign for a type in the nesper.dll first?
Among the configuration settings, there is a "import" list that you could try to clear out.
You can also define the SearchPath (assemblies in this case) that NEsper will use to find its assemblies. Though in practice, the best answer is to use the AssemblyQualifiedName. Using the typed functions i.e. AddEventType() will automatically use the AssemblyQualifiedName.
In the end I resolved the problem by using the Qualified assembly name
configuration.AddEventType("OrderEvent", typeof(Order).AssemblyQualifiedName);
instead of the below:
configuration.AddEventType("OrderEvent", typeof(Order).FullName);

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

Problem with MvcContrib

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.

How do I reference types or modules defined in other F# files? [duplicate]

This will hopefully be an easy one. I have an F# project (latest F# CTP) with two files (Program.fs, Stack.fs). In Stack.fs I have a simple namespace and type definition
Stack.fs
namespace Col
type Stack=
...
Now I try to include the namespace in Program.fs by declaring
open Col
This doesn't work and gives me the error "The namespace or module Col is not defined." Yet it's defined within the same project. I've got to be missing something obvious
What order are the files in the .fsproj file? Stack.fs needs to come before Program.fs for Program.fs to be able to 'see' it.
See also the start of
http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!444.entry
and the end of
http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!347.entry
I had the same problems, and you are right, the order of the files is taken in account by the compiler. Instead of the Remove and Add pattern, you can use the Move Up / Move Down items in the context menu associated to the .fs files. (Alt-Up and Alt-Down are the shortcut keys in most of the standard key-bindings)
All of the above are correct, but how to do this in VS2013 is another question. I had to edit my .fsproj file manually, and set the files in exact order within an ItemGroup node. In this case it would look like this:
<ItemGroup>
<Compile Include="Stack.fs" />
<Compile Include="Program.fs" />
<None Include="App.config" />
</ItemGroup>
I had the same issue and it was indeed the ordering of the files. However, the links above didn't describe how to fix it in Visual Studio 2008 F# 1.9.4.19.
If you open a module, make sure your source file comes after the dependency in the solution explorer. Just right click your source and select Remove. Then re-add it. This will make it appear at the bottom of the list. Hopefully you don't have circular dependencies.
I'm using Visual Studio for Mac - 8.1.4 and i've noticed that some .fs files are not marked as "Compile". You can see this by Viewing Build Output and see if all your files are there and in the correct order.
I've had to manually make sure certain files are marked with "Compile", and have had to move them up and down manually until it "takes".

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