Cannot pass a GCHandle across AppDomains - c#

I have implemented quickfix engine using asp.net and C#.
and i am calling quickfix_net.dll which is written in unmanaged C++.
but i am getting error like "Cannot pass a GCHandle across AppDomains" when calling quickfix_net.dll.
but the same thing is running in console application but not under IIS i.e asp.net
please anybody look into matter.
thanks in advance
Following are my code:
SessionSettings settings = new SessionSettings(tradeClientPath);
ApplicationMessage application = new ApplicationMessage();
FileStoreFactory storeFactory = new FileStoreFactory(settings);
FileLogFactory logFactory = new FileLogFactory(settings);
MessageFactory messageFactory = new DefaultMessageFactory();
SocketInitiator initiator = new SocketInitiator
(application, storeFactory, settings, logFactory, messageFactory);
initiator.start();
Message message = new Message();
OrdType ordType = new OrdType(OrdType.MARKET);
QuickFix42.NewOrderSingle newOrderSingle = new QuickFix42.NewOrderSingle(new ClOrdID("1"), new HandlInst('1'), new Symbol("WAKEN\00110048=2")
, new Side(Side.BUY), new TransactTime(), new OrdType(OrdType.MARKET));
newOrderSingle.set(new OrderQty(10));
newOrderSingle.set(new TimeInForce(TimeInForce.DAY));
Message.Header header = newOrderSingle.getHeader();
header.setField(new SenderCompID("CLIENT1"));
header.setField(new TargetCompID("EXECUTOR"));
message = newOrderSingle;
**QuickFix.Session.sendToTarget(message);** // here i am getting exception
initiator.stop();
Web site reference is : http://www.quickfixengine.org/quickfix/doc/html/index.html

It's a known issue with QuickFix.Net, it only works in-proc. So basically there are not many options, short of changing FIX plugin.

Related

Sharing a business notebook with Evernote API

I'm getting a Evernote.EDAM.Error.EDAMErrorCode.PERMISSION_DENIED error on createSharedNotebook when trying to share a business notebook.
AuthenticationResult busAuthResult = _userStore.authenticateToBusiness(authToken);
var bAuthToken = busAuthResult.AuthenticationToken;
var bNoteStoreUri = busAuthResult.NoteStoreUrl;
TTransport noteStoreTransport = new THttpClient(new Uri(bNoteStoreUri));
TProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
var noteStore = new NoteStore.Client(noteStoreProtocol);
var notebook = noteStore.getNotebook(bAuthToken, notebookGuid);
var sharedNotebook = new SharedNotebook();
sharedNotebook.Email = "test#test.com";
sharedNotebook.NotebookModifiable = true;
sharedNotebook.AllowPreview = true;
sharedNotebook.NotebookGuid = notebookGuid;
noteStore.createSharedNotebook(bAuthToken, sharedNotebook);
The account I'm using has access to share the notebook, so I can't figure out where this error is coming from. I haven't been able to find anything on sharing business notebooks, so any ideas or links would be greatly appreciated!
I think NotebookModifiable is deprecated. Instead, can you add privilege? After that, hopefully you would get another error message that tell you exactly what other parameters like recipientSettings you have to add.

Get StackOverflow exception on web service project but not in winform project

I'm trying to understand why I get stackoverflow exception on one project (Web Service) but not on WinForm project..
Here is the code:
VimClient vimClient = new VimClient();
ServiceContent serviceContent = vimClient.Connect("https://servername/sdk");
UserSession us = vimClient.Login(username, password);
ManagedObjectReference _svcRef = new ManagedObjectReference();
_svcRef.Type = "ServiceInstance";
_svcRef.Value = "ServiceInstance";
NameValueCollection filterForVM = new NameValueCollection();
filterForVM.Add("Name", ServerName);
VirtualMachine vm = (VirtualMachine)vimClient.FindEntityView(typeof(VirtualMachine), null, filterForVM, null);
vimClient.Disconnect();
The Exception is on this line:
VirtualMachine vm = (VirtualMachine)vimClient.FindEntityView(typeof(VirtualMachine), null, filterForVM, null);
What could it be?
Creating new thread with new stack size solved the problem :) thanks

VMware vCenter API with C# - InitiateFileTransferToGuest fails

I'm trying to use the InitiateFileTransferToGuest method to send a file to a VM. Unfortunately, I'm getting stuck. Here's the related code where VClient is the VimClient with an already successfull connection:
GuestOperationsManager VMOpsManager = new GuestOperationsManager(VClient, VClient.ServiceContent.GuestOperationsManager);
GuestFileManager VMFileManager = new GuestFileManager(VClient, VClient.ServiceContent.FileManager);
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, VClient.ServiceContent.AuthorizationManager);
NamePasswordAuthentication Auth = new NamePasswordAuthentication()
{
Username = "username",
Password = "password",
InteractiveSession = false
};
VMAuthManager.ValidateCredentialsInGuest(CurrentVM.MoRef, Auth);
System.IO.FileInfo FileToTransfer = new System.IO.FileInfo("C:\\userlist.txt");
GuestFileAttributes GFA = new GuestFileAttributes()
{
AccessTime = FileToTransfer.LastAccessTimeUtc,
ModificationTime = FileToTransfer.LastWriteTimeUtc
};
string TransferOutput = VMFileManager.InitiateFileTransferToGuest(CurrentVM.MoRef, Auth, "C:\\userlist.txt", GFA, FileToTransfer.Length, false);
First error shows up when getting to the ValidateCredentialsInGuest method. I get this message:
An unhandled exception of type 'VMware.Vim.VimException' occurred in VMware.Vim.dll Additional information: The request refers to an unexpected or unknown type.
If I remove that validation, I get the same error when trying to run InitiateFileTransferToGuest. I've been browsing the API documentation, and threads in VMware forums and a lot of places to be honest. The only pieces of code I've seen posted where it works were in Java and Perl, but the API implementation is a little different than C#. Any idea where to look?
Thank you!
I made it work after testing and making up stuff. I guessed the MoRef for both AuthManager and FileManager doing the following:
ManagedObjectReference MoRefFileManager = new ManagedObjectReference("guestOperationsFileManager");
GuestFileManager VMFileManager = new GuestFileManager(VClient, MoRefFileManager);
ManagedObjectReference MoRefAuthManager = new ManagedObjectReference("guestOperationsAuthManager");
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, MoRefAuthManager);
Now it's working, and I have no idea how.

mongodb gridfs in C# new api

i am new with MongoDB, and i can't find GridFS.
Where can i get GridFS to store files now ?
I can get it this way:
mongoClient = new MongoClient(Settings.Default.MongoDB);
var server = mongoClient.GetServer();
MongoDatabase = server.GetDatabase(Settings.Default.DatabaseName);
MongoDatabase.GridFS...
but GetServer() method is obsolete.
if I get database as here:
MongoDatabase2 = mongoClient.GetDatabase(Settings.Default.DatabaseName);
MongoDatabase2.GridFS... not working
Then i receive IMongoDatabase instead MongoDatabase, and i didnt have GridFS.
Heureka!! Got it! Give me the Nobel prize! :)
var grid = new MongoGridFS(new MongoServer(new MongoServerSettings {Server = new MongoServerAddress(host, port)}), databaseName, new MongoGridFSSettings());
grid.Upload(file.InputStream, file.FileName, new MongoGridFSCreateOptions
{
Id = imageId,
ContentType = file.ContentType
});
I have the same problem. I did find something I thought would solve my problem, the class MongoGridFS. My problem now is that it takes a MongoServer, as it's first arg and times out when I give it a new instance or complains about a connectionstring not found.
var grid = new MongoGridFS(new MongoServer(new MongoServerSettings { Server = new MongoServerAddress(Settings.Default.WizdooMongoConnectionString) }), Settings.Default.WizdooMongoDatabaseName, new MongoGridFSSettings());
grid.Upload(file.InputStream, file.FileName, new MongoGridFSCreateOptions
{
Id = imageId,
ContentType = file.ContentType
});
//Yealds: The settings property 'ConnectionString' was not found.
I suppose I need to give it a connectionstring, but I've been able to do CRUD fine in MongoDB without it. So weird for this service to require it all of a sudden. Maybe you can make it work for you though. I'm going to look in to it more when I have time... should work with correct config. If you get it to work pls give me a hint! Good luck! :)

Database Dataset errors in form designer view

I'm using visual studio 2012, c# and have created several windows form applications but whenever I try to run my program, there is an error with the "designer view":
this.employee_DatabaseDataSet = new Form1.Employee_DatabaseDataSet();
this.tblCustLoginBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.tblCustLoginTableAdapter = new Form1.Employee_DatabaseDataSetTableAdapters.**tblCustLoginTableAdapter();
this.tableAdapterManager = new Form1.Employee_DatabaseDataSetTableAdapters**.TableAdapterManager();
It seems to me that there is a problem with my data source but I have started fresh so I don't see what the problem is.
This is the error that comes up:
"The type name Employee_DatabaseDataSet does not exist in the type form1.form1"
Can someone be so kind to help me please? Thanks for reading
you are missing the () parenthesis pair after Form1
Try this :
this.employee_DatabaseDataSet = new Form1().Employee_DatabaseDataSet();
this.tblCustLoginBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.tblCustLoginTableAdapter = new Form1().Employee_DatabaseDataSetTableAdapters.tblCustLoginTableAdapter();
this.tableAdapterManager = new Form1().Employee_DatabaseDataSetTableAdapters.TableAdapterManager();

Categories