StackExchange.Redis.IDatabase exists in two dlls - asp.net-mvc

I installed Redis StackExchange nuget and things worked fine. But then I installed RedisSessionStateProvider nuget, which installed StackExchange.Redis.StrongName along with it.
Now I am getting the following error,
Error 107 The type 'StackExchange.Redis.IDatabase' exists in both
'e:\Source\packages\StackExchange.Redis.1.0.481\lib\net45\StackExchange.Redis.dll'
and
'e:\Source\packages\StackExchange.Redis.StrongName.1.0.481\lib\net45\StackExchange.Redis.StrongName.dll' E:\Source\MyApp\Helpers\RedisHelper\StackExchangeRedisExtensions.cs 13 37 MyApp
Why is this?

There's a lot of confusion between the strong-named dll and the non-strong-named dll namespaces.
You can easily solve this by using extern alias.
Right click on project references and pick the dll you want to refer, go to properties window. Then, change the Aliases field value to anything you want. E.g: "Redis".
Then go to your consumer source-file and add:
extern alias Redis;
using System;
// ... other references
using Redis::StackExchange.Redis;
namespace Foo
{
public class Program
{
public static void Main(string[] args)
{
using (ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("myConn"))
{
// use StackExchange API here.
}
}
}
}
There's also an issue on StackExchange's repository explaining more about StrongName vs Non-StrongName.

Some methods/properties/interfaces are duplicated in above 2 dlls.
Remove StackExchange.Redis reference to resolve errors.

I faced this issue in an ASP.NET Core app, and this answer solved my issue quickly.

Related

Possibly Bug in Websharper Zafir-Libraries (Beta)

I'm trying to create a Sitelet with SiteletBuilder in C#:
return WebSharper.Sitelets.Content.Page(...)
However, the class Websharper.Sitelet contains Content both as Struct and Class.
So, this does not compile.
Versions of Zafir-Libraries are
Zafir 4.0.152.29-beta5
Zafir.CSharp 4.0.152.29-beta5
Zafir.Html 4.0.56.95-beta5
Zafir.UI.Next 4.0.102.33-beta5
How to reference WebSharper.Sitelets.Content proberly?
Or is this indeed a bug?
Thanks for the report, created ticket: https://github.com/intellifactory/websharper/issues/645
I have been testing with having using WebSharper.Sitelets; and then using with shorter form Content.Page(...). C# can resolve this for some reason, although the name conflict indeed exists in WebSharper.Sitelets.dll

Error with spring security plugin in grails 2.4.0.M1

i'm running into a compilation issue, using grails 2.4.0.M1 and spring-security-core:2.0-RC2
this is the error:
..../target/work/plugins/spring-security-core-2.0-RC2/src/groovy/grails/plugin/springsecurity/ReflectionUtils.groovy:
205: Apparent variable 'org' was found in a static scope but doesn't
refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance
variable from a static context. You misspelled a classname or
statically imported field. Please check the spelling. You attempted
to use a method 'org' but left out brackets in a place not allowed by
the grammar. # line 205, column 18.
application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
^
the problem seems to be around this method
private static GrailsApplication getApplication() {
if (!application) {
application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
}
application
}
on the class ReflectionUtils.groovy,
does anyone else as ran into something like this? if so how do you fixed it?
I fixed this today - https://github.com/grails-plugins/grails-spring-security-core/commit/ef3aab05bfb0eb2f2cbb2c5945f4fc9ca2f0697d
You can make the change that #Bubuntux showed as a temporary workaround, and I'll be releasing 2.0 final in a couple of weeks with this fixed. Hopefully you're not planning on using a Grails M1 release in production, so the delay shouldn't be too much of an issue.
Seems like the ApplicationHolder class was deprecated a long time ago, and now removed on grals 2.4
so i just change the line
application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
to
application = Holders.grailsApplication

dLibs - OpenKinect

Recently I got interested in dLibs, the Java wrapper for OpenKinect.
But I have difficulties in running the codes in eclipse; I've added the libraries based on what I think.
How to run the codes, say the example .pde files?
I've written sth like this to see how it works...
public class Test {
public static void main(String[] args) {
Kinect.loadLibrary( "C:/Users/admin/Dropbox/new_workspace/dLibs/", "freenect.dll" );
Kinect k= new Kinect(0);
System.out.println(k.isReady());
}
}
==========
But I get this error:
#_KINECT_ERROR___#
location: dLibs.freenect.FreenectLibrary.loadLibrary(FreenectLibrary.java:177)
message: Unable to load library : freenect.dll
message: path = "C:\Users\admin\Dropbox\new_workspace\dLibs/freenect.dll"
message: try 'MyKinect.loadLibrary( "your dll path/", "freenect.dll" )'
which the 177 line of the FreenectLibrary is about the loadLibrary(...) method.
Can anyone please help me with that?
I was running the same issue. Make sure you use the 64bit dll file. Also make sure about the path is correct, and the use of / !

Problem with Entity Framework 4 and NUnit

I've got a simple test project I'm trying to convert from the visual studio unit testing framework to nunit. However, I'm encountering a strange error.
private VidRepository _repository;
//Setup the context before each test
[TestFixtureSetUp]
public void TestInitialize()
{
var fakeRepository = new FakeRepository();
_repository = fakeRepository.GetFakeRepository();
}
[Test]
public void CanGetMakes()
{
var makes = _repository.GetMakes();
Assert.AreNotEqual(0, makes.Count());
}
When I run the test CanGetMakes it dies in the TestFixtureSetup method with the error.
Could not load file or assembly
'CompanyName.Data.VidEntities,
Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its
dependencies. An attempt was made to
load a program with an incorrect
format.
I've added and removed the reference to the project a couple times with no luck, and it also works when I change it back to the Microsoft unit testing framework (using Microsoft.VisualStudio.TestTools.UnitTesting;) which is very odd to me.
Does anyone have any suggestions.
Thank you,
Brian
I went through my projects and set the platform target to any cpu and it fixed the problem.

asp.net mvc code not getting compiled on server

i have this code in one of my asp.net mvc views:
<%Html.RenderFile(#"C:\Members\newsletters\welcome.html");%>
I have created an extension on the Html class to read in a file. the code looks like this:
public static class HtmlRenderer
{
public static void RenderFile(this HtmlHelper helper_, string path_)
{
var reader = new StreamReader(path_);
var contents = reader.ReadToEnd();
helper_.ViewContext.HttpContext.Response.Write(contents);
}
}
This all works perfectly when i run in visual studio on my desktop but when i ftp these files to the server, i get the following error in the browser:
Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderFile' and no extension method 'RenderFile' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
The HtmlRenderer class is in a namespace with my controllers so there is no other external assembly reference needed.
Does anyone have any idea how this could be happening or what i am doing wrong ?
You need to compile the project and then deploy (xcopy or publish from VS) to the server.
Googled and found something.Does the server has .net 3.5?
Try to publish the web on a local IIS7 or IIS6.( Right click project "Publish" ).
You have a good chance you already get a more specific error during "publish".
If not run the page on your local IIS6 or 7 and see if you get an error.
i tried doing a full refresh (deleting everything on the server and republishing and now everything works fine..
so i am happy that everything is working but still have no clue why it wasn't before.

Resources