NHibernate UnableToLoadProxyFactoryFactoryException - visual-studio-2010

I have a similar problem to the one posted
here.
Here's my code (c#):
var nHConfig = new Configuration().Configure();
var sessionFactory = nHConfig.BuildSessionFactory();
The actual configuration is detailed in an App.config file:
<session-factory>
...
<property name="proxyfactory.factory_class">
NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
</property>
...
</session-factory>
I am referencing both NHibernate.dll and NHibernate.ByteCode.Castle.dll.
Here's the error I get:
failed: NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException : Unable to load type 'NNHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class.
Here is the solution accepted in the aforementioned post (answer given by Kevin Crowell):
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.
My problem is this -
When I try running the application after changing the target platform, Visual Studio raises the following error:
Error while trying to run project. Cannot start debugging. The assembly to be debugged was built with a platform incompatible with the current system.
Any ideas what I might be doing wrong, and what I can do to correct or work around the problem?
Many thanks!

Referencing NHibernate.ByteCode.Castle.dll from your project is not necessary since it is a dependency resolved runtime. You must ensure that the assebly is present in the private bin path of your application ( near the executable for a desktop app, in the /bin path for a web application ) and that the other dependencies of that assembly are present too.
As an additional reference, from version 3.2.0 GA there is a default proxy factory pointing to an internal LinFu proxy, see this JIRA:
https://nhibernate.jira.com/browse/NH-2586
so if you have any special needing to use the castle proxies, yoo can completely avoid the configuration of the proxy factory.

Related

Debugging resource strings are unavailable

I am working on a Silverlight web application in Visual Studio 2010.
I recently made the mistake of updating to the latest version Silverlight when prompted through the browser. Consequently, I was unable to build (or even load) my Silverlight application.
To get around this, I installed the Silverlight 5 Developer runtime - which enabled me to build and deploy the application.
However, when I deploy to a locked down test machine, and run the web application, I get an exception something like the following:
"Debugging resource strings are unavailable..."
The test machine appears to have the 'standard' 64-bit Silverlight runtime installed, version 5.1.20513.0.
It appears that the runtime on the test machine is the 'standard' runtime, not the 'Developer' runtime. Because the test machine is locked down, I am unable to install the 'Developer' runtime - so I am forced to find a setup that will both compile on my development machine, and will run on test.
I have tried several combinations of reinstalling Silverlight, with various back versions - but nothing seems to work.
So I am in a quandary:
Compiling on the dev machine won't work without the 'Developer' runtime.
The application cannot be run on the test machine without the Developer runtime being present - which cannot be installed (and shouldn't be necessary - in principle - given that it was working before!).
Is there a 'trick' here that I am missing?
Thanks.
Apparently, I was missing a (required) setting in the Web.Config file.
The "Debugging Strings not available" appears when there is a fault in the application, but the relevant fault code(s) cannot be translated into something more human-readable, (due to the absence of the required DLLs or some such).
After having updated the Web.Config, the problem disappeared.
It turns out that it was a Key/Value pair that was missing from Web.Config:
<add key="DashboardDataRetrievalMethod" value="UseSummaryTable" />
The application was specifically looking for this, and complained with a rather generic error message with no stack trace etc.

ros::init(...) throws an error - Windows roscpp

I'm trying to use ros in cpp with Visual Studio 2012. I wrote the publisher and subscriber tutorial (http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29) and first, I configure the project as says in the guide (http://wiki.ros.org/win_ros/hydro/Msvc%20SDK%20Projects).
Then i compiled an linked the publisher, but when I tried to run it, ros::init(argc,argv,"talker") throws an exception... The console says that I ROS_MASTER_URI is not defined but I've got it defined
There are 2 images here:
https://www.dropbox.com/s/o12m0l38gaxiugi/error1.png -
https://www.dropbox.com/s/ocdmf0wj6rj0962/error.png
Can anyone helps me?
Thanks in advance
So, I had the same issue, although I didn't set the ROS_MASTER_URI globally.
I managed to get around this specific issue by adding
ROS_MASTER_URI=http://localhost:11311
to the debugging environment variables (Project->Properties->Configuration Properties->Debugging->Environment).
However, after implementing the above I got an uncaught exception (Unhandled exception at 0x768bc41f in ros_demo.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0028f0e4..).
That went away when I built, compiled and ran the project in release mode (which matched my ROS SDK build).
I got the idea for the release/debug build from here:
xstring isn't an OSG specific object, so the error is elsewhere in the
3rd party dependency chain. As I know nothing about your OS and
software setup I can't speculate what this might be.
In general though this type of error could well be a linking issue -
for instance Visual Studio is hopeless at handling different libs
being built debug and release and will crash randomly.
That was fun to discover..

Castle Windsor not resolving when build configuration is "AnyCPU" or "x64"

I am using CastleWindsor to register and resolve NHibernate dependencies in a console app and everything works fine as long as I build in x86 platform. But if I change this platform to "AnyCPU" or "x64" it stops resolving the components. Is there a CastleWindsor issue that I am not aware of or am I doing something wrong? Help please.
Here is some code that I am using (nothing fancy):
Registration Code:
container.Register(Component.For<ILogger>()
.ImplementedBy<Log4netLog>(),
Component.For<Repository.INHibUnitOfWork>()
.ImplementedBy<Repository.NHibUnitOfWork>().LifestyleTransient()....
Resolve code:
_windsorContainer = new WindsorContainer();
_windsorContainer.Install(FromAssembly.This());
_windsorContainer.Resolve<ISessionFactory>();
Getting an error on the last line. No component for supporting the service ISessionFactory was found. The code runs fine if I build it in x86 configuration.
I found the problem. One of the project (in the list of 20 projects) was set to build using x86 configuration. After changing its build settings I was able to build and run the project using ANYCPU setting. Thanks for following up and pointing me to the right direction.

Access violation when compiling in debug

I'm trying to profile a C++ project in Embarcadero RAD Studio 2010. To do this I wanted to use AQTime, but I'm running into a bit of a problem.
I can compile and run the application in release mode. But when I compile in debug mode, using the settings mentioned at http://smartbear.com/support/viewarticle/18053/, I get an access violation.
... faulted with message: 'access
violation at 0x062324bd: read of
address 0x62324bd'. Process stopped.
Use Step or Run to continue.
It seems to come when I load a bunch of dll's at the startup. But since it goes well in release mode I can't seem to figure out what could be the cause.
When the access violation occurs I get thrown out into assembly and that isn't one of the languages I'm fluent in ;)
EDIT : When scanning the .exe with Dependency Walker I get a message saying that the following files can't be found
CC32100MT.DLL
INET140.BPL
RTL140.BPL
VCL140.BPL
IESHIMS.DLL
Could this be the problem somehow? Are these debugspecific or is Dependency Walker not giving me correct information? The same files are said to be missing when I try a release compiled version to.
I'm running on Windows 7 x64, if that could be part of the issue. I have had problems before with the symlink-look-alike (user/AppData/Local...) that MS used for some folders. Notably when I ran an apache server and the htdocs folder actually wasn't located where the server thought it was (and where it appeared to be) :)
Have you tried disabling dynamic rtl which can be found in the C++ builder linker options pane?

What is a Windows command-line EXE's "side-by-side configuration" and how do I correct it?

I have a simple .exe written in C++ (built with Visual Studio 2005) that tests some hardware using a supplied API. It works fine on the Windows 7 machine I built it on, but when I copy it to another (Windows 7) machine and run it (from the command-line) I get:
The application has failed to start
because its side-by-side configuration
is incorrect. Please see the
application event log or use the
command-line sxstrace.exe tool for
more detail.
What is "side-by-side configuration"?
I ran sxstrace.exe and read the usage info. It appears I would need to instrument my exe to generate a log file for sxstrace.exe to be useful?
I imagine the problem is my exe requires DLLs that either don't exist on the other machine, or are the wrong version. How do I find out what DLLs my exe uses, and what versions it links to on my machine (where it works)? Any other advice on copying it to another machine and getting it running? Would more information help?
mfawzymkh's answer to the "application has failed to start because the side by side configauration is incorrect" question (linked to in the question spirulence linked to in his answer to this question) appears to apply to this question also. mfawzymkh writes:
You can resolve this issue by either
one of these 1- Install VC8 Debug CRT
2- Build you app as statically linked
And mfawzymkh's comment on that same answer explains how to build as statically linked:
when you build it in VS, go to
projects->settings->C/C++->Code
Generation and choose Runtime Lib
options to be /MTd instead of /MDd
I did that and the side-by-side configuration message is gone. (And after installing something else for the DLL I was using, my EXE works.)
For what it's worth, I encountered the same issue. In the Event Viewer I had an error message that read:
Activation context generation failed for "C:\\MyExe.exe".Error in manifest or policy file "C:\\MyExe.exe.Config" on line 12. Invalid Xml syntax.
Sure enough, I'd changed a connection string and left out the closing quote. Added that back in and it solved the issue.
"when you build it in VS, go to projects->settings->C/C++->Code Generation and choose Runtime Lib options to be /MTd instead of /MDd" worked for me, although I was interested in the Release version instead of the Debug version.
Microsofto says:
/MT Causes your application to use the multithread, static version of the run-time library. Defines _MT and causes the compiler to place the library name LIBCMT.lib into the .obj file so that the linker will use LIBCMT.lib to resolve external symbols.
/MD
Causes your application to use the multithread- and DLL-specific version of the run-time library. Defines _MT and _DLL and causes the compiler to place the library name MSVCRT.lib into the .obj file.
Applications compiled with this option are statically linked to MSVCRT.lib. This library provides a layer of code that allows the linker to resolve external references. The actual working code is contained in MSVCR100.DLL, which must be available at run time to applications linked with MSVCRT.lib.
Are you suffering from the same issue as this guy? Side-by-side assemblies, Windows 7, and Visual Studio 2005

Resources