NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException - nhibernate

I have the following code set up in my Startup
IDictionary<string, string> properties = new Dictionary<string, string>();
properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
properties.Add("dialect", "NHibernate.Dialect.MsSql2005Dialect");
properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
properties.Add("connection.connection_string", "Data Source=ZEUS;Initial Catalog=mydb;Persist Security Info=True;User ID=sa;Password=xxxxxxxx");
InPlaceConfigurationSource source = new InPlaceConfigurationSource();
source.Add(typeof(ActiveRecordBase), (IDictionary<string, string>) properties);
Assembly asm = Assembly.Load("Repository");
Castle.ActiveRecord.ActiveRecordStarter.Initialize(asm, source);
I am getting the following error:
failed: NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException : Unable to load type 'NNHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class.
Possible causes are:
The NHibernate.Bytecode provider assembly was not deployed.
The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.
I have read and read I am referecning the All the assemblies listed and I am at a total loss as what to try next.
Castle.ActiveRecord.dll
Castle.DynamicProxy2.dll
Iesi.Collections.dll
log4net.dll
NHibernate.dll
NHibernate.ByteCode.Castle.dll
Castle.Core.dll.
I am 100% sure the assembly is in the bin. Anyone have any ideas?

This problem occurs when NHibernate.ByteCode.Castle.dll was built with a different target platform as your project. To test this, change your program target platform from one or more of the following:
x64 to x86
x86 to x64
"Any CPU" to x86
"Any CPU" to x64
If any of those solve your problem, then you know that you just need to synchronize the DLL and your target platform.

I had this problem also, my solution was to add in the Assembly that creates session following code.
private NHibernate.ByteCode.Castle.ProxyFactoryFactory requiredButNeverUsed;

Related

Setting up pythonnet for .net using NuGet

Iam trying to develop a simple calculator program embeddeding python in .net,I wanna reference pythonnet from NuGet to include it in my project
I installed pythonnet v2.3.0 using NuGet,I also have python 3 installed in my system
It would be nice if some one give me step by step instruction to embedd python net
form1.cs code :
using System;
...
using Python.Runtime;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
PythonEngine.Initialize();
}
private void button1_Click(object sender, EventArgs e)
{
int num1 = int.Parse(a.Text);
int num2 = int.Parse(b.Text);
result.Text = (num1 + num2).ToString();
using (Py.GIL())
{
dynamic np = Py.Import("numpy");
}
}
}
}
When I use using(Py.GIL()) line in my code it compiler shows
System.BadImageFormatException: 'Could not load file or assembly
'Python.Runtime, Version=2.3.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. An attempt was made
to load a program with an incorrect format.'
This issue is likely caused by architecture (32-bit/64-bit) mismatch between Python.Runtime.dll and your Python.
pythonnet 2.3.0 NuGet packages currently published on nuget.org include two versions of the Python.Runtime.dll assembly: 32-bit(x86) and 64-bit(x64). There is a known issue with this package not installing the correct reference in the project, even if the project platform is set to 64-bit:
https://github.com/pythonnet/pythonnet/issues/472.
Usually the x86 reference gets installed, and if your Python is 64-bit, you get the above exception.
To fix this:
Remove the existing assembly reference from the project.
Manually add reference to the correct assembly from the installed nuget package (e.g. your_solution_dir\packages\pythonnet_py35_dotnet.2.3.0\lib\net40\x64\Python.Runtime.dll)
Changed the CPU architecture from AnyCPU to x64 and it fixed the issue.
I had same problem. I was running KerasExampleWinApp Sample (keras.net). The error was:
"...Python.Runtime, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies..."
To solve it, I just deleted the Nugget Reference and reinstalled it.

The type 'Application' is defined in an assembly that is not referenced. gtk-sharp, Version=2.12

I am building an application using GTK# 2.12 version. I installed MonoDevelop for that. Made a sample application.
When I changed the setting from GTK#3 to GTK# 2.12 on the project then all references are updated to GTK#2.12.
When I am compiling the project then compiler throws an error.
/local/mnt/workspace/vkumbhan/work/Program.cs(25,25): Error CS0012: The type 'Application' is defined in an assembly that is not referenced. You must add a reference to assembly 'gio-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f'. (CS0012)
class MainClass
{
public static void Main(string[] args)
{
Application.Init(); //error came this line
MainWindow win = new MainWindow();
win.Show();
Application.Run(); //error came this line
}
}
When I looked at the references for the Application class then I found it the Application refer to gtk-sharp 3.0.0.0.
For checking GTK# 2.12 installed or not.
apt-cache policy libgtk2.0-0 libgtk-3-0
both versions are installed on the machine.
Could you please help me, how to resolve the issue?
Find the command line: Please help to update references 2.12.0.0 instead of 3.0.0.0
/usr/lib/mono/msbuild/15.0/bin/Roslyn/csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:/usr/lib/mono/gac/atk-sharp/3.0.0.0__35e10195dab3c99f/atk-sharp.dll /reference:/usr/lib/mono/gac/gdk-sharp/3.0.0.0__35e10195dab3c99f/gdk-sharp.dll /reference:/usr/lib/mono/gac/glade-sharp/2.12.0.0__35e10195dab3c99f/glade-sharp.dll /reference:/usr/lib/mono/gac/gtk-sharp/3.0.0.0__35e10195dab3c99f/gtk-sharp.dll /reference:/usr/lib/mono/4.5-api/Mono.Posix.dll /reference:/usr/lib/mono/4.5-api/mscorlib.dll /reference:/usr/lib/mono/gac/pango-sharp/3.0.0.0__35e10195dab3c99f/pango-sharp.dll /reference:/usr/lib/mono/4.5-api/System.Core.dll /reference:/usr/lib/mono/4.5-api/System.dll /debug+ /debug:portable /optimize- /out:obj/Debug/Sample.exe /subsystemversion:6.00 /resource:gtk-gui/gui.stetic,gui.stetic /target:winexe /utf8output MainWindow.cs Program.cs Properties/AssemblyInfo.cs gtk-gui/generated.cs gtk-gui/MainWindow.cs "/tmp/.NETFramework,Version=v4.5.AssemblyAttributes.cs"
Thanks!
The easiest way to solve this is to create a new Gtk# app in MonoDevelop, which defaults to Gtk# 2.12, since the designer needs that version.
Then you can copy the class files (*.cs) from the project that does not compile.

VB.NET desktop application error : Could not load file or assembly 'log4net, Version = 1.2.10.0 Culture = neutral, PublicKeyToken = 692fbea5521e1304'

I've setup a VB.NET desktop application in a Windows 8.1 pro 64-bit PC. After doing server configurations I'm trying to login to the application. It's when I'm getting the following error message:
Could not load file or assembly 'log4net, Version = 1.2.10.0 Culture = neutral, PublicKeyToken = 692fbea5521e1304'or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I've installed SAP Crystal Reports 13.0.3 64-bit yet it's still not working.
What is the reason behind this problem?
Check you Application files in Project Settings,find status of log4net dll whether included or not .Make it included in your project as below :
Problem solved.
The problem raised due to the mismatch in version of the log4net.dll file. My solution had log4net version = 1.2.9.0, while it needed the version = 1.2.10.0, hence the exception occured. I replaced the existing log4net.dll file with the one which has appropriate version and the problem was solved.

docx4j.NET installation issue

I've installed docx4j.NET 3.0.1 from Nuget with vs2012.
When I try to use the library with this call
WordprocessingMLPackage.load(inputS, "");
I receive this error:
System.TypeInitializationException:
The type initializer for 'org.docx4j.openpackaging.packages.OpcPackage' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'slf4j-api,
Version=1.7.6.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies
The version of slf4j-api in the docx4j.net 3.0.1 distribution is 1.7.5.0.
Is there a problem in the distribution of package?
Check that the list of referenced DLLs in your VS project includes slf4j-api. If not, add it.
If you have the DLL properly referenced, then as per the sample code in say https://github.com/plutext/docx4j.NET/blob/master/docx4j.NET/src/samples/c%23/Docx4NET/DocxToHTML.cs, you might need something like (note the bottom line):
// Programmatically configure Common Logging
// (alternatively, you could do it declaratively in app.config)
NameValueCollection commonLoggingproperties = new NameValueCollection();
commonLoggingproperties["showDateTime"] = "false";
commonLoggingproperties["level"] = "INFO";
LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(commonLoggingproperties);
ILog log = LogManager.GetCurrentClassLogger();
log.Info("Hello from Common Logging" );
// Necessary, if slf4j-api and slf4j-NetCommonLogging are separate DLLs
ikvm.runtime.Startup.addBootClassPathAssembly(
System.Reflection.Assembly.GetAssembly(
typeof(org.slf4j.impl.StaticLoggerBinder)));

Upgrading App from .NET 3.5 to 4.0, COM fails now

I have an application that I am upgrading from the .NET 3.5 to the .NET 4.0 framework. It uses a COM library which is referenced. It works no problem in 3.5 but after converting to 4.0 I have issues getting the COM to work. The COM is from a 3rd party so we didn't develop it ourselves.
I get the following COM error (generic COM error, not specific to the COM object itself): hr = 0x8007000b
CLR gives me: 'The invocation of the constructor on type 'Skype_Business_Launcher.Main' that matches the specified binding constraints threw an exception.' Line number '3' and line position '5'.
And the C# logs:
=== Pre-bind state information ===
LOG: User = \phillip
LOG: DisplayName = Interop.SKYPE4COMLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Skype Business Launcher, Version=1.0.5.0, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file:
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///bin/Debug/Interop.SKYPE4COMLib.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
I removed the pathname for security reasons but I have checked all the path information and it's all correct. Also the COM library file exists where it's pointing to. It's also copied to the OBJ folder within the project as well.
Originally I was getting an error about the COM library not supporting embedded types so I made "Embed Interop Types" false (it was true below) and the error went away but I'm not sure if thats connected to this error or not so I thought I'd mention it just in case.
Again, it works just fine with 3.5.
Thanks,
A shot in the dark: it looks like you are using the x64 version of the framework. Was that already the case with 3.5 ? And is the COM server a DLL or an EXE ?
If the COM server is a DLL, there needs to be a "bitness" match between the DLL and your program.
when you convert your project to 4.0 the IDE can perform a issue to convert COM library into 4.0.
when you convert your project to 4.0 remove com library then Re include it in your project then i thing it should be works.