|
VC++ project is Win32 console dll.
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
Divyang Mithaiwala wrote: VC++ project is Win32 console dll.
That's your problem. If you want to use a dll using Namespaces then the dll must be managed. If it is unmanaged then you will have to import the function of the dll using DLLImport. Check out articles related to calling Win32 APIs using C# in CP.
Hope this helps...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Any other method to use it. Becoz when i use it as DLLImport then at run time it will give error that "Attempt to read or write protected memory".
thanx.
Divyang Mithaiwala
|
|
|
|
|
Now I am not sure what your problem is?
Refer to this[^] and this[^] for more details on DllImport.
Hope this Helps...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
I am trying to get a Label to display the date I selected from a Calendar control. This is the code I copied from http://www.asp.net and it works. However, I want additional functions to just this. I need to:
1. The calendar is minimized until the mouse hover over it or a small button is click to activate the calendar control. (Either way is fine, as long as the calendar control is not maxed display all the time, it takes up a lot of unnecessary space.)
2. To change the date display from MM/DD/YYYY to DD/MM/YYYY
I copied my codes from www.asp.net/quickstart but it's not showing properly here so I removed the prefix of asp: here. Kindly modify the codes below. Thank you.
void Date_Selected(object s, EventArgs e) {
Label1.Text = "Selected date is: " + Calendar1.SelectedDate.ToShortDateString();
}
Calendar Example
<:Calendar id=Calendar1 onselectionchanged="Date_Selected" runat="server" />
<:Label id=Label1 runat="server" />
-- modified at 0:15 Monday 27th March, 2006
|
|
|
|
|
I think you might be better off using AJAX. Look for the Anthem lib on SourceForge.
|
|
|
|
|
I cant find the Anthem lib you mentioned in Sourceforge. I'm writing in C#, not C++. Is there no other way around it in Visual Studio 2005 itself instead of a third-party solution?
|
|
|
|
|
tanpanjang wrote: I cant find the Anthem lib you mentioned in Sourceforge.
http://anthem-dot-net.sourceforge.net/[^]
tanpanjang wrote: I'm writing in C#, not C++.
Yes this is the C# forum, I dont know why you mention that...
tanpanjang wrote: Is there no other way around it in Visual Studio 2005 itself instead of a third-party solution?
You will have to emit some form Javascript to hide the emitted object. AJAX/Anthem will take of that for you.
|
|
|
|
|
|
i have a file demo.txt And that Contain
1 29 38 29 53
2 34 53 54 34
4 54 65 23 62
5 3 23 24 25
I want get small value of a row
Example:
i read row 1 and get small value is 1
How will i do
anhtin
|
|
|
|
|
Read the line into a string and split that string on the space character. Loop through the array that you get, converting each string into an integer and checking which one is the smallest.
---
b { font-weight: normal; }
|
|
|
|
|
assume the following method in a COM
virtual void * __stdcall Print(BSTR msg){
char * buf= new char[128];
sprintf(buf,"return by print interface");
return (void *)buf;
}
how should I handle the returned pointer by the method above in C#, so that I can get the proper string set by the method?
Vincent
|
|
|
|
|
If this is COM you can't pass back memory allocated by new. You need to allocate the char array with AllocCoTaskMem(). After that you should just be able to to a Marshal.PtrToStringAnsi() call on the value.
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/[^]
|
|
|
|
|
Also, is it legal for void* to be an [out] parameter to a COM interface? IIRC this is not legal since COM would be unable to marshal the underlying data.
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/[^]
|
|
|
|
|
hi,Jared
my COM was built in pure unmanaged code.I can't use AllocCoTaskMem,can I?
Vincent
|
|
|
|
|
dragooooon lee wrote: my COM was built in pure unmanaged code.I can't use AllocCoTaskMem,can I?
You can use Marashal.AllocCoTaskMem(). But I don't think that applies in this case since this is purely managed. I assumed your example was in C++. I believe that since it's all managed the CLR marshaller will do the dirty work. I haven't every written a purely managed COM interface implemenation though so I would check some documenation.
Can you post the IDL file for the COM interface? That would help out a bit.
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/[^]
|
|
|
|
|
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(853b4626-393a-44df-b13e-64cabe535dbf),
nonextensible,
pointer_default(unique)
]
interface IMyComponent : IUnknown
{
[id(1), helpstring("method Initialize")] void * __stdcall Print(BSTR msg);
};
[uuid(0c6bb614-8563-49ea-b5ce-e6b7febebc27)]
coclass RtpSource
{
interface IMyComponent ;
};
Vincent
|
|
|
|
|
System.AccessViolationException caught when I use CoTaskMemAlloc()
Vincent
|
|
|
|
|
|
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(853b4626-393a-44df-b13e-64cabe535dbf),
nonextensible,
pointer_default(unique)
]
interface IMyComponent : IUnknown
{
[id(1), helpstring("method Initialize")] void * __stdcall Print(BSTR msg);
};
[uuid(0c6bb614-8563-49ea-b5ce-e6b7febebc27)]
coclass RtpSource
{
interface IMyComponent ;
};
------------------------------------------------------------
C# code
IntPtr p = ((IMyComponent)rtpsource).Print(s);
StringBuilder sb = new StringBuilder();
sb.Append(Marshal.PtrToStringBSTR(p));
Vincent
|
|
|
|
|
Two problems are jumping out at me.
- I don't think that it's legal for a COM method to return void* without a specification of a custom marshaller. Otherwise it's impossible for COM to figure out how to Marshal the data between processes and/or apartments. Then again I'm not a COM expert so one of them might want to chirp in here.
- Shouldn't the COM method be returning an HRESULT? Otherwise how do you detect failure?
Also, can you post the implementation of the COM interface or at least the Print method? And how did you aquire the rptsource variable (please post that code as well).
Jared Parsons
jaredp@beanseed.org
http://jaredparsons.blogspot.com/[^]
|
|
|
|
|
it's ugly since it's just a test.
thanks anyway.maybe I need to read some books about interoperation to figure it out.
Vincent
|
|
|
|
|
It's ugly since it's just a test.
Thanks anyway.Maybe I need to read some books about interoperation to figure it out
Vincent
|
|
|
|
|
I've got an application, and i want to to be able to spawn an AppDomain with it, and supply it with some Main method args that it can then use to connect to the creating app, and then continue execution as normal.
How do i do this when creating something using:
AppDomain.CreateDomain()?
Cheers
Tris
-- modified at 18:06 Sunday 26th March, 2006
|
|
|
|
|
How does one determine the version of windows that thier program is running on?
|
|
|
|