|
You can do it via a Visual Studio Addin. If you'd care to download MoXAML Power Toys (follow the link in my sig), and you can download the source code for an add in that works with source files. There are plenty of samples in there where the code is manipulated via Visual Studio (Note, it's a VS2008 solution, but the code works in VS2005 as well).
|
|
|
|
|
It's built-in, RTFM:
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv" template.vb /command "edit.goto 10"
http://msdn.microsoft.com/en-us/library/xee0c8y7(VS.80).aspx
(Don't use the /edit switch.)
|
|
|
|
|
Hello!
I want to pass an array of double values into unmanaged C code.
Example:
<code>
[DllImport("DummyDll.DLL")]
public static extern int nCalcAll(double* dpData, int Nx, int Ny);
static void Main(string[] args)
{
Console.WriteLine("Call native dll...");
double[] array = {32 * 32};
int result = nCalcAll(array, 32, 32);
Console.WriteLine("...calc all from c dll");
}
</code>
At the line "int result = nCalcAll(array, 32, 32);" it throws a runtime error.
How can I solve this problem?
I've never dealt with Interop before, so any help would be greatly appreciated.
Thanks!
|
|
|
|
|
What kind of error, exactly?
You may need to specify the calling convention as cdecl, the default is stdcall.
|
|
|
|
|
Thanks for all your help!
It was indeed the Calling Convention. When I set it to CallingConvention.Cdecl, everything runs fine
|
|
|
|
|
Blackwurst wrote: it throws a runtime error
I don't think so, I expect it does not even compile as your function invocation (with array) doesn't match the prototype (with pointer).
Here[^] is all you probably need to know, with array examples and all.
|
|
|
|
|
I assumed the code he posted was not his actual code - there is more in there that just doesn't make sense. That array containing only 1024.0 is definitely suspicious, if the second and third arguments to that function are supposed to be about the width and height of the array.
So, I think he just typed an example here
|
|
|
|
|
So I guess I was wrong. Ok, then his code just sucks.
|
|
|
|
|
Did you downvote your own message? That is not supposed to be possible.
|
|
|
|
|
Well, I thought that was Blackwurst..?
I haven't found a good way to vote my own posts, it's impossible from all open proxies I've tried so far
|
|
|
|
|
harold aptroot wrote: Well, I thought that was Blackwurst..?
Possibly one of his mates too, by the vote count. From their combined vote weighting it may have been Rookyworst.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Lol Rookyworst, I actually laughed, not just "the internet lol"
Thanks for testing that for me
|
|
|
|
|
Hi Everyone, Sorry for long code below. I thought it was the best way to express my problem. I would be glad if you could forward me to an article or could just answer the below questions. (in spite of reading many articles.I'm confused about the below issues)
- On click of a button, server/client will want server/client to do something(in addition to what's below) but I couldn't implement it.Errors and Errors
- Is it good practice to use CanRead and DataAvailable properties of NetworkStream not to face with exceptions?
- When server or client want each other to do something(two way job request) Is this implementation capable of handling it?
- On each loop at client side, I open and close connection. Is it good practice?
- Can I determine the size of the byte buffer according to the incoming stream? I currently put a random size
Thanks in advance for your patience and help.
Regards
private void AnaForm_Load(object sender, EventArgs e)
{
thdListener = new Thread(new ThreadStart(listenerThread));
thdListener.Start();
}
public void listenerThread()
{
try
{
string ipAdress = GetIP();
IPAddress IPadres = IPAddress.Parse(ipAdress);
IPEndPoint ipEndPoint = new IPEndPoint(IPadres, 8000);
TcpListener tcpListener = new TcpListener(ipEndPoint);
tcpListener.Start();
while (true)
{
listenerSocket = tcpListener.AcceptSocket();
ntrStream = new NetworkStream(listenerSocket);
if (listenerSocket.Connected)
{
if (ntrStream.CanRead)
{
byte[] byt = new byte[500];
ntrStream.Read(byt, 0, byt.Length);
MemoryStream ms = new MemoryStream(byt);
BinaryFormatter bf = new BinaryFormatter();
hashTableInfo.Clear();
hashTableInfo = (Hashtable)bf.Deserialize(ms);
}
if (msc.Name.Remove(0, 4) == hashTableInfo["MasaNo"].ToString())
{
thdHandler = new Thread(new ThreadStart(handlerThread));
thdHandler.Start();
}
}
}
}
catch (Exception)
{
}
}
public void handlerThread()
{
ntrStream = new NetworkStream(listenerSocket);
try
{
if (ntrStream.CanWrite)
{
MemoryStream msTime = new MemoryStream();
msTime = new MemoryStream();
BinaryFormatter bfTime = new BinaryFormatter();
bfTime.Serialize(msTime, hashTimes);
byte[] bellekSure = new byte[msTime.Length];
bellekSure = msTime.ToArray();
ntrStream.Write(bellekSure, 0, bellekSure.Length);
}
if (ntrStream.CanWrite)
{
MemoryStream msDrinks = new MemoryStream();
BinaryFormatter bfDrinks = new BinaryFormatter();
bfDrinks.Serialize(msDrinks, hashDrinks);
byte[] bellekKafe = new byte[msDrinks.Length];
bellekKafe = msDrinks.ToArray();
ntrStream.Write(bellekKafe, 0, bellekKafe.Length);
urunlerGuncellendi = false;
}
}
catch (Exception)
{
}
}
//Client
private void Client_Load(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
while(true)
{
try
{
tcpClient = new TcpClient("serverName", 8000);
if (tcpClient.Connected)
{
ntrStream = tcpClient.GetStream();
MemoryStream msSip = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(msSip, htTableInfo);
byte[] byt = new byte[msSip.Length];
byt = msSip.ToArray();
if (ntrStream.CanWrite) ntrStream.Write(byt, 0, byt.Length);
if (ntrStream.CanRead)
{
byte[] bytTimes = new byte[500]; ntrStream.Read(bytTimes, 0, bytTimes.Length);
MemoryStream msTimes = new MemoryStream(bytTimes);
BinaryFormatter bfSure = new BinaryFormatter();
hashTimes.Clear();
hashTimes = (Hashtable)bfSure.Deserialize(msTimes);
if (InvokeRequired) this.Invoke(new dlgApplyTimes(applyTimes));
else applyTimes();
}
if (ntrStream.DataAvailable)
{
byte[] bellekKafe = new byte[500];
ntrStream.Read(bellekKafe, 0, bellekKafe.Length);
MemoryStream msKafe = new MemoryStream(bellekKafe);
BinaryFormatter bfKafe = new BinaryFormatter();
hashDrinks.Clear();
hashDrinks = (Hashtable)bfKafe.Deserialize(msKafe);
if (InvokeRequired) this.Invoke(new dlgApplyDrinks(applyDrinks));
else appyDrinks();
}
ntrStream.Close();
tcpClient.Close();
tcpClient = null;
}
}
catch (Exception)
{
}
Thread.Sleep(3000);
}
}
modified on Tuesday, October 5, 2010 8:42 AM
|
|
|
|
|
Message Closed
modified 23-Nov-14 5:54am.
|
|
|
|
|
So can I find the answers to all of my questions with WCF?
|
|
|
|
|
Yeah, WCF.
And, no, the server shouldn't tell the client to do anything; it merely serves.
|
|
|
|
|
Let's say the server asked client to do something. is it not possible? Then what is the way of telling client to do something and report back? and Is it also not possible in WCF?
|
|
|
|
|
It may be possible, but that is not what servers do; it's poor design.
|
|
|
|
|
Hi,
Please help me regarding a doubt. i have a .xml file which is having around 3000 nodes, now I want to retrieve the name attribute of those nodes for which store attribute>30. Please suggest the esaiest way to do it.
Thanks,
Inder....
|
|
|
|
|
Hi All,
How can we determine if a user-certificate is contained in a smartcard or if it is installed in the system itself?
I wasn't able to find a .NET class that does this?
Thanks in advance...
Sunil
|
|
|
|
|
There is no inbuilt class for smart card in .net ,
you have to use winscard.dll wrapper .
go through the below link in CP
A Smart Card Framework for .NET[^]
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
As much as i know even if a certificate comes in a card then also it has to be installed in your personal store.
While reading the cetificate you need to insert the smart token in order to execute ComputeSignature . And if you set the silent parameter to false while using ComputeSignature it will automatically reads the card and asks for password for the certificate (if any).
|
|
|
|
|
Hi all
Your help\opinion is required on a bothering subject I am debating with for a long time...
Tools: .NET 2.0, VS2005. C#
The story:
I am designing a platform that uses plugins (written by her users) and does something with them.
The plugins are mainly dll file(s) that implement some declared interface.
My platform architecture is as such:
The platform sits at certain directory (say c:\PlatformBin).
The plugins sits in user defined location (say c:\UserPlugins)
Upon starting the platform, it accepts at run time (registry key) the plugins directory, traverse and instantiate all plugins resides there.
The problem:
User plugin is eventually a dll, that implements given interface (say UserPluginDll.dll). This dll can use, if\as needed, other external dll's that needs to be in the same directory. (say User3rdPartyDll.dll)
When the platform loads the plugins, it explicitly loads the UserPluginDll.dll file (through Assembly.LoadFile(UserPluginDll.dll);). This works fine.
The problem happens when the platform actually access at runtime to the user code in the plugin, that uses the user 3rd party dll (User3rdPartyDll.dll)
The CLR can't find the relevant User3rdPartyDll.dll file and raises up an exception "file not found...").
The suggested solutions:
Here are some tricks and solutions that I have tried\disqualified:
1. Use GAC (not an option)
2. Add to the appDomain private bin path for the c:\UserPlugins directory (and its subdirectories) - not working since private bin path (and other similar tricks) is always relatively to the app bin path (c:\PlatformBin), and I don't want to create this unnecessary coupling between the users plugins directory and the platform bin directory
3. Use <Probing> element in application config file - not good (and not working as well from some reason), since the plugins directory is learnt at runtime and I don't want the user to go and edit the app config file and change the plugins directory there.
4. Use AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve method, that is raised exactly when the CLR fails to locate the necessary dll.
Summary and question:
I think I will use this forth option eventually, but it also demonstrates a compromise from my side, as it means that the CLR first have to fail and then request my help (at runtime), instead of automatically allows me to tell him at the very first beginning were else he needs to search for its missing dlls at runtime.
I would have expect that CLR will allow me to add additional search paths for searching dll's at runtime, and it drives me crazy that I can't do so !!!
Any one can help ? have other suggestions ?
-- Modified Tuesday, October 5, 2010 3:32 AM
|
|
|
|
|
Member 3941620 wrote: CLR first have to fail and then request my help
Programming by error - I love it.
Isn't there a reference path in there somewhere, maybe that can be set in the userdll.dll at runtime.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi
The solution can't come from the user code side, since the problems occures before actually access him.
In addition, I don't want to force\expect the user to be aware of my (CLR) limitations and have hime handle some technical issues, not directly relating to its domain\knowladge
If, from the other hand, you are aware of an option that allows to define the assembly, upon loading, other assemblies to load when needed - that can certainly be done from my side (the platform) and I will be happy to be notified about such an option...
Thanks
Shultz
|
|
|
|