|
you must define the static as a field, now you get Compiler Error CS1525.
Try this:
static int c = 0;
private void method()
{
c++;
}
Regards,
Wernand.
|
|
|
|
|
I'm creating a C# .net program which contains one .exe file and one .dll file.
I need to create an installer for this program to let the user install my program from for example a cd.
What is it I should do? I really have no idea. I know there is an installer class i .net but the documentation is terrible about how one uses it.
Could anyone point out what I need to do?
|
|
|
|
|
The Installer class is different from an application installer. The class is for unit installations (like installing a control in the VS.NET toolbox) or custom actions.
To create an installation program for your application, add a new project to your solution in VS.NET and select "Setup and Deployment", then a Windows Installer project. It's pretty self-explanitory, but refer to the documentation if you have questions.
Keep in mind that this is a very lite version of a Windows Installer IDE and can only do basic things. For a professional package, try Wise for Windows Installer or InstallShield's version, which is much, much more expensive.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
You should add a setup project to your solution. You can also add Installer class to your main project for the custom actions during the setup. You can look up the msdn for further documentation.
|
|
|
|
|
Hi All,
Excuse me for my bad English.
Who can tell me where I can found the constants needed to program win32 api within C#.
For example in the Win32 API reference, I found the following procedure:
<br />
AddFontResourceEx<br />
The AddFontResourceEx function adds the font resource from the specified file to the system. Fonts added with the AddFontResourceEx function can be marked as private and not enumerable.<br />
<br />
int AddFontResourceEx(<br />
LPCTSTR lpszFilename,
DWORD fl,
PVOID pdv
);<br />
Where fl stands for Flags used to define how the private font resource is loaded.
FR_PRIVATE
FR_NOT_ENUM
I can find in my books that these constants in C# corresponds with the flags:
<br />
public const Int32 FR_PRIVATE = 0x10;<br />
public const Int32 FR_NOT_ENUM = 0x20;<br />
But now my question.
Where can I find the values like 0x10, 0x20 or all the others?
I can't find it anywhere, who can help me with this.
Thanks and regards,
Wernand
The Netherlands
|
|
|
|
|
I have found it on the msdn site from Microsoft.
You can simple search in C++ SDK with findstr you get then the values:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include>findstr "FR_PRIVATE" *.h
WinGDI.h:#define FR_PRIVATE 0x10
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include>findstr "FR_NOT_ENUM" *.h
WinGDI.h:#define FR_NOT_ENUM 0x20
|
|
|
|
|
Remember to just include the WinGDI.h in your program, and not to use the values directly.
Your English is very good by the way, probably better than most people's Dutch! (Zeker weten).
Ciao,
Pauwl
|
|
|
|
|
Um, he's coding a C# app which doesn't use/understand include files. He has to define these (as consts, an enum, whatever) in his source.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Try this site[^]
The examples are for VB, but I'm sure it wouldn't be too hard to translate it to C#.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
|
|
|
|
|
Has anyone seen a bug in IE or IIS where you have a small image repeated a bunch of times in a page and it sometimes doesn't show up? Hitting refresh a few times seems to fix it. I've noticed this on several IIS based projects (asp.net and perl based) on different machines.
Todd Smith
|
|
|
|
|
IMO its an IE bug, I get it alot. Perhaps due to the 2 "streams" limit, and IE asking for the same file multiple times.
It could also be people running IIS on WInXP SP1.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
IE 6.0 has a problem with its cache. Once it hits the configured limit, the indexing goes nuts and it can't find cached resources any more.
Empty Temporary Internet Files, and everything should work.
|
|
|
|
|
Hi,
I need to write out a program that will change the time zone based the the nearest Domain Controller. Any ideas? Please help!!!
|
|
|
|
|
I have several forms with controls, and I need to execute some lines of code only when I run my program. But I don't want that these lines are executed when I'm in Visual Studio and open the windows form file.
Thanks in advance.
|
|
|
|
|
You can't explicitly detect Visual Studio, but you can detect whether there is a debugger attached.
See System.Diagnostics.Debugger.IsAttached .
|
|
|
|
|
|
Take a look at the 'Component.DesignMode' property - that's probably what you want.
--
Russell Morris
"So, broccoli, mother says you're good for me... but I'm afraid I'm no good for you!" - Stewy
|
|
|
|
|
|
Hi,
i have a dynamic link library (compiled in VC++ 7.0) and want to use the functions(and types,structs) in my c# program, i already read some articles on this msg-board about unmanaged code, just those only show easy functions with simple return-paramaters.
eg.:
[DllImport("kernel32")] public static extern void Sleep(int dwMilliseconds);
What if the functions return parameter is a pointer to a complex structure(eg.: chained lists)?
As example, i am trying to import functions from a packet construction library called libnet, alone the init function of this library looks like this:
libnet_t * libnet_init(int injection_type, int8_t *device, int8_t *err_buf);
My question now is can someone explain/show/link me how i marshall such return/call by reference variables, will i have to write a wrapper class which acts as a interface between my c# program and the c++ dll, if yes how?
If you can help provide an easy code snippet and show me how i need to start or point me to a book/website/etc.
Thanks in advance....
|
|
|
|
|
Declare the function with return type "IntPtr". An IntPtr can point to any address in memory, and you can de-marshal the object:
IntPtr ptr = libnet_init(...);
Object obj = Marshal.PtrToStructure(ptr);
to use the object in C#, you have to write an interface.
|
|
|
|
|
Hope you can give me a little bit more help anyway here is code snippet how i would use the functions / structs in c++ and create a simple TCP packet.
<br />
#include <libnet.h><br />
int main(int argc, char **argv)<br />
{<br />
libnet_t *lib_pointer = NULL;
libnet_ptag_t tcp,ip;
char *device = NULL;<br />
char errbuff[1024];<br />
write int;<br />
<br />
lib_pointer = libnet_init(LIBNET_RAW4, device, errbuff);<br />
<br />
tcp = libnet_build_tcp(..,..,..,.,lib_pointer,...);<br />
ip = libnet_build_ip(..,..,..,lib_pointer,.....);<br />
write=libnet_write(lib_pointer);<br />
My main question is how can i use the types, consts which are defined in libnet.h ala the .dll file i compiled in vc++. You made the statement about this IntPtr, which i marshal to a PtrToStruct, well so i could also create a PtrToStruct type in c# and let it point to eg. libnet_t?
What i did not really understand is the interface thing you mentioned, could you explain this a bit more deeply?
Thanks for your time again.
|
|
|
|
|
There are a few ways of doing this:
1. Hardest solution: Write a custom marshaller in Managed C++ that converts(or wraps) the non-managed type into a managed type;
2. Take the approach of returning an IntPtr, then defining a custom interface to the embedded type.
3. Easiest solution: If the return type can be decomposed into simpler managed variable types, define the structure in the managed part:
function decl:
my_type* getMyTypeStuff( .... );
where my_type =
struct my_type {
int foo;
int bar;
HWND* gobble;
char[] yadda;
}...;
managed declarations:
struct MyType {
Int32 foo;
Int32 bar;
IntPtr gobble;
byte[] yadda (or char[] yadda, or IntPtr yadda...)
}
[DllImport(....)]
public static extern MyType[] getMyTypeStuff(....);
You may need a MarshalAs attribute in there, not sure, I'm running from memory. Actually, take all of the above with a grain of salt, as I don't have any reference material in front of me at the moment...
Jeremy Kimball
|
|
|
|
|
You could also make use of unsafe coding by using the unsafe keyword. Make shure to set up the compiler options for allowing unsafe code in the project. For further instructions check the help provided with your c# package.
|
|
|
|
|
I like to define my class variables at the top of the file. When I add extra controls in the design view, the new item's definitions are slotted in between those I have already put there. I guess the auto-code-insertion is looking for the last private definition below the class keyword. Can anyone point me at information about how this is actually handled?
|
|
|
|
|
Hello!
I want to implement simple COM object which will communicate with Oracle database somewhere on internet. It looks rather simple. But I have a possibility to use either C++ or C# technology. As I do not know C# very well: someone can help and put some comments - which technology would be simpler to write/manage ?
Or maybe there exists some ready-to-use sample?
Thanks for help
|
|
|
|