|
Just looked for info on the BackgroundWorker class.
Found This[^]
First thing in the description was
"...The Silverlight BackgroundWorker class provides..." I stopped immediately. Sorry for the feeble braincells here; just want to make sure that I don't have to require special software on the users machine.
I took a quick look at this[^] page and I see mostly stuff about internet and web browsers.
Was my view of the forest obliterated by a tree ?
|
|
|
|
|
The link I pointed you at is the standard .NET BackgroundWorker - it doesn't need Silverlight (or anything extra that isn't already needed to run c#) A quick look says it it pretty much the same class anyway - all the events and properties are the same.
MS do reuse names - look at the number of Timer classes you could play with if you wanted to!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Hi
I've got a Delphi32 DLL that I have to call from C# and have a .h, .hpp, and .bas header file.
Would it make most sense to use the .hpp file to create a Class that will wrap the DLL? Seems so to me.
Unfortunately, I don't do C++
It sort of makes sense, but not completely. Mostly, I know void * should be IntPtr, and char * should be string. But that's about it.
For instance,
const char bapiDll[] = "BAPI32.DLL";
HINSTANCE hLib;
enum TParamType { literal, reference, list } ParamType;
void * pRPC;
should turn into
const string bapiDll = "BAPI32.DLL";
uint HINSTANCE, hLib;
enum TParamType { literal, reference, list } ;
IntPtr pRPC;
Yes? No?
But what do I do with the prototypes and what follows inside the actual guts of the thing? like
void RPCBPropGet ( char * s, char * t);
which obviously has something to do with
void TRPCBroker::RPCBPropGet ( char * s, char * t)
{
iRPCBPropGet(pRPC, s, t);
}
and
TRPCBroker::TRPCBroker()
{
hLib = LoadLibrary(bapiDll);
if((unsigned)hLib<=HINSTANCE_ERROR)
{
char bfr[40];
wsprintf(bfr, "Failure loading library: %s", bapiDll);
MessageBox(NULL, bfr, toolSet, MB_OK|MB_APPLMODAL);
UnLoad = true;
}
. . .
iRPCBPropGet = (void (__stdcall*)(void *, char *, char *)) GetProcAddress(hLib, "RpcbPropGet");
. . .
UnLoad = false;
pRPC = iRPCBCreate();
};
Any good references out there that'll cover this without me having to spend days reading through everything I don't want to know? Or anyone incredibly bored with no life who wants to hold my hand through all 139 lines of it (including empty and comment lines :p )?
|
|
|
|
|
Luc (Pattyn) had a nice article on 'P/Invoke' that Ive found useful .. http://www.perceler.com/articles1.php?art=pinvoke1[^]
Im sure there used to be some automated tools out there that would assist in converting function prototypes (c++) into their C# .NET equivalent, but cant find them right now
I had a similar issue, needing to use PGP SDK (Commercial) from C# - I ended up with essentially 3 layers :-
a) Interop Layer
b) C++ DLL exposing/combining lower level PGP SDK functions into higher functions - for example, the encrypt_file procedure uses key management functions, encrypt functions from the SDK
c) the PGP SDK DLL
It all depends on what functionality you need to expose from your DLL how you 'wrap it'
There's another approach, but I havnt used it which is c++/CLI
|
|
|
|
|
Luc's looks promising. Thanks.
I think I tried one of the automated online converters once...and it came up with line after line of "ya gotta do this part by hand".
|
|
|
|
|
Have a look at x86 calling conventions[^]
I assume that header file is for C++ Builder, and the delphi dll will use what the article calls 'Borland fastcall' which is different from 'Microsoft fastcall' - so you're probably going to need to wrap the functions and expose them using the __stdcall calling convention.
GenJerDan wrote: everything I don't want to know?
Not the most promising attitude for a developer - and calling conventions is something I would think you need to understand.
Best regards
Espen Harlinn
|
|
|
|
|
I've never had to deal directly with DLLs, or at least not to try to use one that wasn't friendly with the rest of the program....and I started I started in 1992 or so.
Push comes to shove, I don't even have have to do this now. I've got Delphi sitting here, too.
I just think it might be a good idea if I didn't have to keep running a virtual machine to write these things. (Delphi 5 won't install on 64bit Windows.)(Yes, I said Delphi 5)
The __stdcall is already there in the header, so I assume the DLL was written to work with it.
|
|
|
|
|
GenJerDan wrote: I've got Delphi sitting here, too
Delphi has always been one of my favourite development tools, I've been using it since version 1 - but, seriously, Delphi 5, that makes me nostalgic.
GenJerDan wrote: I started in 1992
I believe I was working on a C++ IDE for IBM and OS/2 at that time.
GenJerDan wrote: __stdcall is already there in the header
I assumed the code above was from the header file, and I only saw __stdcall in one place.
Go for Delphi XE3[^], assuming you haven't done any magic related to getting notified on object destruction, which was something many Delphi developers did, porting the code should be pretty easy.
Good luck
|
|
|
|
|
Read up on Marshalling and unmanaged code. Normally C# can handle unmanaged code pretty well.
Although it might take some fiddling (searching) .
[EDIT]
Take in account that older code still takes ASCII strings or worse (1 byte vs 2 bytes) and even C# integers can be C++ longs, ...
[/EDIT]
|
|
|
|
|
Since you have the .h and .hpp files for your DLL, you might want to give this a shot. I have used it extensively to help me generate pinvoke signatures. The link for the generator is included on the page.
pinvoke signature generator[^]
|
|
|
|
|
I am a newbie to C#, my development environment is:
Visual Studio 2010 Ultimate Edition
Sql Server 2005
Programming Language C# 2010
I've a form with Unbound Datagridview, from which data is save to Sql Server 2005 by looping through For..Each and pass SQL INSERT Statement when user clicks Save button without any problem.
Now what I need is a way that for same Save button, if data is saved in Sql Server then DataGridView will bind to that records so that if user want to Update/Delete/Add data he/she just need to edit the data and again press Save button. All records will share the same unique ID. It's a products database, and when user click save it will generate a transaction Id same for all products user enter when saving. So I think I need to generate a Select statement and retrieve all those records user save through that Unique ID, but then how to bind it to DataGridView datasource and how to Update/Delete through SqlAdapter or other?
Thanks and best regards
Ahmed
|
|
|
|
|
I'm trying to add Microsoft IObjectSafety Interface to my code. I send string "MyParam" from JavaScript and catch it in my C# code like this:
private string myParam = "Empty";
public string MyParam
{
get
{
return myParam;
}
set
{
myParam = value;
}
}
After I add the IObjectSafety interface this doesnt work anymore, I get error interfaces cannot contain fields. How do I get the MyParam without using fields?
This is the code:
public interface IObject
{
[DispId(1)]
string MyParam; <--- error
};
public class WMC.PlayerLoader : IObjectSafetyImpl, IObject
{
#region [IObject implementation]
private string myParam = "Empty";
public string MyParam
{
get
{
return myParam;
}
set
{
myParam = value;
}
}
#endregion
|
|
|
|
|
Are you sure that an interface[^] is the correct mechanism for your problem?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I need to add the IOBjectsafety interface to get rid of the message ActiveX might not be safe message when using it locally, I don't think there is any other way around that except verisign. All the methods on the interface work fine except getting that string.
|
|
|
|
|
Joni_78 wrote: string MyParam; <--- error
Your implementation of MyParam is a property, not a field. You should declare this as string MyParam { get; set; } in the interface definition (which overcomes the interface containing fields error as well).
|
|
|
|
|
I've newer done this like that before. Do I need to change anything in this, or should it work as it was?
public class WMC.PlayerLoader : IObjectSafetyImpl, IObject
{
#region [IObject implementation]
private string myParam = "Empty";
public string MyParam
{
get
{
return myParam;
}
set
{
myParam = value;
}
}
#endregion
|
|
|
|
|
Nm, I got it now. Thank you ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
You're welcome. I'm glad you got it sorted.
|
|
|
|
|
Hi, i am new to asp.net. i need to display complete URL of my website in web browser. if user navigate to some other page the url must include address of that page too. plz do help..
|
|
|
|
|
Varsha R wrote: Hi, i am new to asp.net
Fair enough, but isn't that a great big hint as to which forum you should post this question in instead?
|
|
|
|
|
|
How do you programmatically expand a url link to its true location?
Do you know about tinyurl.com and baidu.com? Baidu.com is a search engine that tries to discourage people from using their web site to make metasearch engines by hiding their links in a way that is a lot like how tinyurl.com works. TinyUrl.com is a web site where, if you want to present someone with a link to something and that link is long, you can use tinyurl to produce a tiny url for presentation purposes.
Anyway, what I want to do is to find a way to programmatically take the link http://www.baidu.com/link?url=mW91GJqjJ4zBBpC8yDF8xDhiqDSn1JZjFWsHhEoSNd85PkV8Xil7qccoOX3rynaE (the first link in a search for Jessica Alba using baidu.com) and have it return the actual link, http://baike.baidu.com/view/270790.htm . That is just one example. What I want to do is not specific to Jessica but for using Baidu.com as part of my group of search engines in my meta search engine project.
Maybe there is a way of using the WebBrowser class but I did not see a member that was the URL.
Maybe there is a way of using WebRequest and WebResponse.
|
|
|
|
|
By requesting the URL shown on Baidu. Then analyse the response. Somewhere there you'll find the redirection information, either in the HTTP header (e.g. a REDIRECT response code plus the correct URL) or a JavaScript in the HTML document, or something similar.
Do not forget that Baidu could find out that you do too many surch requests, and just stop responding to your requests (e.g. block your IP address).
|
|
|
|
|
I am a VB.NET Programmer learning C#. One of my applications I transfered over to C# via an online converion tool. I am receiving an error which I do not see why it's causing an error.
What I have now is:
try {
if (System.IO.File.Exists(srcedest) == false) {
My.Computer.FileSystem.RenameFile((dest), newName) sheet.Cells(row, 1).value;
}
} catch (Exception ex) {
txtLog3.AppendText(sheet.Cells(row, 1).value);
}
With the error of "expecting ;" at the "sheet" in My.Computer.FileSystem.RenameFile((dest), newName) sheet.Cells(row, 1).value;
Why would this cause an error since you don't put a ";" until the end of a statement?
Thanks in advanced.
daveofgv
modified 27-Nov-12 16:52pm.
|
|
|
|
|
Dunno, maybe remove the newName) and stick a ) just before the ; ?
|
|
|
|