Problem with referencing Castle.ActiveRecord.dll - c#

I downloaded recent sources of Castle.ActiveRecord from github. I succesfully compiled it against vs2010 (targetting .Net 4.0)
I added reference to Castle.Core, Castle.ActiveRecord.dll assembly and using Castle.ActiveRecord; to my simple project (Console app, .Net 4.0)
And i got the following compile error
"The type or namespace name 'ActiveRecord' does not exist in the namespace 'Castle' (are you missing an assembly reference?)"
But this namespace exists in this assembly (I checked via object browser)
What is the problem?

Castle.Core and Castle.ActiveRecord both have a dependency on System.Web. System.Web does not exist in the .NET Client Profile (either 3.5 or 4). Look further down in your compile errors/warnings and you'll see:
The referenced assembly "Castle.Core"
could not be resolved because it has a
dependency on "System.Web,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" which
is not in the currently targeted framework
".NETFramework,Version=v4.0,Profile=Client".
Please remove references to assemblies
not in the targeted framework or
consider retargeting your project.
Go to Project Properties... Application... Target framework... and switch it to ".NET Framework 4" and you should be good.

Related

.net5 windows api calls with CSWinRT

I am using the Windows.Devices.Bluetooth library in a WPF application using the .net 5.0 framework.
I have referenced the windows api by installing the CSWinRT nuget and using the target framework moniker in my csproj file like this:
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
This is instead of adding references to windows.winmd and windowsruntime.dll as you had to do pre-.net5. I am able to use the windows library with no problem, but I am also using a class library made from a different project using .net 4.7.2 which also references/uses the Windows.Devices.Bluetooth library and thats when im getting this error:
Severity Code Description Project File Line Suppression State
Error CS0012 The type 'BluetoothLEDevice' is defined in an assembly
that is not referenced. You must add a reference to assembly 'Windows,
Version=255.255.255.255, Culture=neutral, PublicKeyToken=null,
ContentType=WindowsRuntime'. 128 Active
So i can access the library directly but not through the dll. Maybe its a problem that the dll uses a different framework?
Does anyone know how to solve this?
The solution to this was to upgrade the class library project .net 5 so that both projects are using the same framework.

.NET Core 3.1 and Could not load file or assembly System.Data.Entity

The similar problem is written here, but not totally same.
I have a new Core 3.1 web project and old .netFramework 4.0 project working with EntityFramework (like BLL).
I'm trying to create an instance of the class from that BLL and getting an error "System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. No such file"
I've installed NuGet packages EntityFramework and EntityFrameworkCore, but it didn't help. In references of the Core 3.1 project I can't find any Entity library. How can I fix it?
Also I tried to add reference to a file System.Data.Entity.dll, but having another error then - "Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)"

Error when using RazorTemplates library: 'CS0012: The type 'System.Attribute' is defined in an assembly that is not referenced'

On some machines, executing a razor template via RazorTemplates works OK.
On others, I receive the following message:
TemplateCompilationException
error CS0012: The type 'System.Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Info:
This is within a WPF application running on .NET 4.7.
The assembly has a reference to System.Runtime.4.3.0\lib\net462\System.Runtime.dll (v4.1.1.0)
However at runtime, this assembly does not show up in the 'Modules' list.
It seems the Attribute object exists in both System.Runtime and mscorlib.
Looks like this is an underlying issue somewhere between win10 and the RazorTemplates library.
In the end i switched from RazorTemplates to RazorEngine: https://github.com/Antaris/RazorEngine
And there is a page here that explains how to fix the problem via a Resolver:
https://github.com/Antaris/RazorEngine/issues/416
System.Runtime is part of the .Net Framework and is installed in the GAC during framework installation.
This could happen for two possible reasons:
It's not on the machine.
It's the wrong version.
For the machines this fails on check what version of the .Net runtime they have and/or inspect the GAC for this file and version.
Missing the framework, install it. :-)
If machines have a version but it's not the expected version do either:
Install the correct framework version
Use a binding redirect in your config file

ASP.NET Core migration to 1.1 - Razor can't load types

After upgrading my project from 1.0 and project.json to 1.1 and .csproj using VS2017, the project runs fine in VS, but when start it using dotnet run (or deploy it to Azure), all the views fail.
The error message is this:
One or more compilation references are missing. Possible causes include a missing 'preserveCompilationContext' property under 'buildOptions' in the application's project.json.
The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
+
public class _Views_News_Index_cshtml : Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyTeam.Models.General.PagedList<ArticleViewModel>>
.........
It seems as if the views are unable to compile because they don't have access to the C# stuff.
I am running on .NET Framework 4.6.1. This is my csproj: https://github.com/severisv/MyTeam/blob/master/src/MyTeam/MyTeam.csproj
Why is this happening? How do I fix it?

Does Scintilla need a directive? I keep getting an error?

So, when I drag in Scintilla to my C# form, and try to run it, I get the error:
The type or namespace name
'ScintillaNet' could not be found (are
you missing a using directive or an
assembly reference?)
The error appears to be coming from the designer for Form1.
I also get the warning (but not error):
The referenced assembly "ScintillaNet"
could not be resolved because it has a
dependency on "System.Design,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" which
is not in the currently targeted
framework
".NETFramework,Version=v4.0,Profile=Client".
Please remove references to assemblies
not in the targeted framework or
consider retargeting your project.
So, I can't run my program...
What's wrong, and how do I fix it? I've installed scintilla just like how the directions for it suggested...
I was also experiencing this error (although I am hosting in WPF not WinForms). It was caused by Visual Studio 2010 defaulting the project to .Net 4.0 Client profile rather than the full .Net 4.0 profile.

Categories