|
Hi All,
I am a newbie to .NET and have a possibly simple doubt.
How can I invoke .NET functionality from C code?
Something like reverse JNI.
Thanks in advance for the help.
|
|
|
|
|
Either:
Register your .NET code for COM Interop, then invoke it through COM. This is the easier method.
Or:
Use the .NET hosting interfaces to load the CLR into your process, then load the appropriate .NET code. This is the hard way.
For .NET 1.1, see C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Tool Developers Guide\docs\Hosting Interfaces.doc. For .NET 2.0, see 'Hosting Interfaces for .NET Framework version 2.0' in MSDN Library, or online here[^].
|
|
|
|
|
I'm working on a C# WPF based web application prototype. I have a WebBrowser control to display web pages. I also need to do some http requests outside of the WebBrowser using HttpWebRequest. I'm logged in to a site so I need cookies sent, but HttpWebRequest does not seem to automatically send them, so these requests are failing. Somehow I need to convince HttpWebRequest to send the cookies for that site. This seems like a very basic thing to do, but I'm tearing my hair out trying to figure out how!
Anyone have any ideas? Since it seems (to me) to be such a basic requoirement, I thought there might be a property I could set on the request to tell it to include cookies. Alternatively, if I could get the cookie collection from the WebBrowser somehow and directly set it to the request I assume that would do it. Or am I missing something?
Thanks!
|
|
|
|
|
Hi,
I would like to know if some component vendors have a DateTimePicker replacement. I don't mean a calendar or any complex component, just a DateTime picker. Optimally it would add what lacks to the microsoft control, like changing the Culture, accepting null values, text formatting, custom fields (like what is available with the win32 control) and so on (I am aware of the free components showcased here at CP). Thank you
|
|
|
|
|
I want to display some values like Windows Task Manager - Performance:
Commit Charge (K) -- Peak
Physical Memory (K) -- Total, System Cache
How can I get this values using PerformanceCounter ?
Thanks.
|
|
|
|
|
Is there a WPF equivalent of the System.Windows.Forms.ActiveControl property? I've looked through all the properties and methods in System.Windows.Window and nothing has struck me.
|
|
|
|
|
Hi
We are migrating our WSE 2 based [File Transmitting Solution] to MTOM based,
in order to provide support of big file transfer in less time. Message size
using MTOM is decreased up to 20% because of different of size between
binary and base64 transfer. But processing time is much higher on both
server and client. And again we reach at same point where overall time of
whole file upload process is higher than our old base64 based method. For
every transfer, wse3 is taking extra time (upto 10 secs on each request) on
file upload upto 7 MB.
Seems like it is because of converting binary to Base64 for generating
digital signature
Is there any way through we can avoid this whole security process. Because
of our application nature, processing time and transmit size is more
important for us instead of message security.
Thanks
Shahzad Godil
|
|
|
|
|
I have a client/server app where communication between clients and server is done through remoting.
It can be tricky getting two machines on the same LAN to send messages back and forth.
My conclusion is that the two machines need a trusted relationship. I think this can be accomplished in a domain by making a group that all remoting users are members of.
Without a domain (just using "workgroup") I know I can make it work by having user accounts replicated on each machine so that each machine trusts the users on the other machines, simply because they are also users on the local machine.
There must be a better way. Anyone know it ?
________
42-Huh?
|
|
|
|
|
I've developed a visual c++ game within micrsoft visual studio.net 1.0. Basically the game involves moving a sprite around a 2d region to various targets, the game is setup such that assistive force is applied by the sidewinder 2 force feedback joystick. I'm struggling a little now with improving the graphics.
I would like to display a bitmap image as the background, another bitmap image as the targets and a transparent bitmap as the sprite. This is the code i'm using at the moment:
It draws a white background and i have a bitmap as the sprite (i would like to make it transparent and maybe even blit it to animate it) and blue circles as the targets. I also get a screen flicker problem and the game crashes out after a little while, i guess this is due to a buffer filling up?
you can see a screen shot from my game here: www.personal.leeds.ac.uk/~men0aphw/image1.jpg
Any help or ideas would be greatly appreciated!
Many thanks!!
ANDY
//variables for the bitmap
HBITMAP g_hGrid = NULL; // Grid Bitmap object
INT g_nGridW, g_nGridH; // and dimensions .................
later on......
//will do the drawing
case WM_PAINT:
currentTime = time(NULL);
timeElapsed = difftime(currentTime, startingTime)- pauseTime;
SetDlgItemText(hDlg, IDTIME_C, ctime(¤tTime));
minutes = timeElapsed / 60;
seconds = timeElapsed - minutes*60;
if(minutes<10 && seconds <10)
sprintf(timePassed_s, "0%d %d", minutes, seconds);
else if (minutes<10 && seconds>=10)
sprintf(timePassed_s, "0%d:%d", minutes, seconds);
else
sprintf(timePassed_s, "%d:%d", minutes, seconds);
SetDlgItemText(hDlg, IDTIME, timePassed_s);
SetDlgItemText(hDlg, IDFORCE, ffCurrentMagStr);
sprintf(numStr, "%d", joy_x);
SetDlgItemText(hDlg, IDJOYX, numStr);
sprintf(numStr, "%d", joy_y);
SetDlgItemText(hDlg, IDJOYY, numStr);
sprintf(score_s, "%d", score);
SetDlgItemText(hDlg, IDSCORE, score_s);
sprintf(numStr, "%.0lf", totalDamping);
SetDlgItemText(hDlg, IDDAMP, numStr);
sprintf(numStr, "%d", current_travel);
SetDlgItemText(hDlg, IDTRAVEX, numStr);
sprintf(numStr, "%d", travelled_total);
SetDlgItemText(hDlg, IDTOTTRAV, numStr);
OnPaint( hDlg );
//Get access to the needed device context
hWndGrid = GetDlgItem( hDlg, IDC_RENDER_WINDOW );
//Move the picture to the joystick position
MoveWindow(hWndGrid, joy_x-15, joy_y-15, 50, 50, TRUE);
// Make sure the picture window is visible.
ShowWindow(hWndGrid, SW_SHOW);
//UpdateWindow( hDlg );
return TRUE;
case WM_DESTROY:
//create a static data file
CreateStaticData(userId);
// Cleanup everything
KillTimer( hDlg, 0 );
FreeDirectInput();
return TRUE;
}
//-----------------------------------------------------------------------------
// Name: OnPaint()
// Desc: Handles the WM_PAINT window message
//-----------------------------------------------------------------------------
VOID OnPaint( HWND hDlg )
{
PAINTSTRUCT ps;
HDC hDC;
HPEN hpenOld;
HPEN hpenBlack;
HBRUSH hbrOld;
HBRUSH hbrBlack, hbrRed, hbrYellow, hbrBlue, hbrGreen, hbrLightBlue, hbrOrange, hbrWhite;
HRGN hrgn;
hDC = BeginPaint( hDlg, &ps );
if( NULL == hDC )
return;
// Everything is scaled to the size of the window.
hpenBlack = GetStockPen( BLACK_PEN );
hpenOld = SelectPen( hDC, hpenBlack );
// Draw force feedback bounding rect
MoveToEx( hDC, FEEDBACK_WINDOW_X, FEEDBACK_WINDOW_Y, NULL );
LineTo( hDC, FEEDBACK_WINDOW_X,
FEEDBACK_WINDOW_Y + FEEDBACK_WINDOW_HEIGHT );
LineTo( hDC, FEEDBACK_WINDOW_X + FEEDBACK_WINDOW_HEIGHT,
FEEDBACK_WINDOW_Y + FEEDBACK_WINDOW_HEIGHT );
LineTo( hDC, FEEDBACK_WINDOW_X + FEEDBACK_WINDOW_HEIGHT,
FEEDBACK_WINDOW_Y );
LineTo( hDC, FEEDBACK_WINDOW_X,
FEEDBACK_WINDOW_Y );
//create different colour brushes
hbrBlack = GetStockBrush( BLACK_BRUSH );
hbrWhite = CreateSolidBrush(RGB(255, 255, 255));
hbrRed = CreateSolidBrush(RGB(255, 0, 0));
hbrYellow = CreateSolidBrush(RGB(255, 255, 0));
hbrBlue = CreateSolidBrush(RGB(0, 0, 255));
hbrGreen = CreateSolidBrush(RGB(0, 255, 0));
hbrLightBlue = CreateSolidBrush(RGB(100, 200, 200));
hbrOrange = CreateSolidBrush(RGB(255, 150, 0));
hbrOld = SelectBrush( hDC, hbrBlack );
//colour the bounding rectangle
hrgn = CreateRectRgn(FEEDBACK_WINDOW_X+1, FEEDBACK_WINDOW_Y+1, FEEDBACK_WINDOW_X+ FEEDBACK_WINDOW_HEIGHT-1, FEEDBACK_WINDOW_Y+ FEEDBACK_WINDOW_HEIGHT-1);
FillRgn(hDC, hrgn, hbrWhite);
// my new code to try and display a background image
/////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//new code to erase background
// LRESULT CALLBACK WindowProc(
// HWND hwnd, // handle to window
// UINT uMsg, // WM_ERASEBKGND
// WPARAM wParam, // handle to device context (HDC)
// LPARAM lParam // not used
//);
//calculate the joystick position
joy_x = MulDiv( FEEDBACK_WINDOW_HEIGHT, g_nXForce + DI_FFNOMINALMAX,
2 * DI_FFNOMINALMAX );
joy_y = MulDiv( FEEDBACK_WINDOW_HEIGHT, g_nYForce + DI_FFNOMINALMAX,
2 * DI_FFNOMINALMAX );
joy_x += FEEDBACK_WINDOW_X;
joy_y += FEEDBACK_WINDOW_Y;
//if low vision is on draw a bigger control object
if(!lowVisionOn)
Rectangle( hDC, joy_x-10, joy_y-10, joy_x+11, joy_y+11 );
else
Rectangle( hDC, joy_x-15, joy_y-15, joy_x+16, joy_y+16 );
int x, y;
//draw the targets
int i;
for(i=0; i<targetsnum; i++)
="" {
="" x="targets_x[i];
" y="targets_y[i];
" if(i="">= currentTargetNum){
if(trajectoryOn && i!=0)
DrawTrajectory(hDC, i);
if(highlightOn && i == currentTargetNum)
SelectBrush( hDC, hbrRed );
else
SelectBrush( hDC, hbrBlack );
if(!lowVisionOn)
Ellipse( hDC, x-10, y-10, x+11, y+11 );
else
Ellipse( hDC, x-15, y-15, x+16, y+16 );
}
}
//select the current target
targetX = targets_x[currentTargetNum];
targetY = targets_y[currentTargetNum];
//if force feedback is on draw the dead zone
if(ffOn == 1){
Arc(hDC, targetX -fDeadZone, targetY-fDeadZone, targetX+fDeadZone,
targetY+fDeadZone, targetX+fDeadZone, targetY, targetX+fDeadZone, targetY);
}
//check whether the target has been hit
hrgn = CreateEllipticRgn(targetX-radius, targetY-radius, targetX+radius, targetY+radius);
//display the hit zone
FillRgn(hDC, hrgn, hbrBlue);
if(PtInRegion(hrgn, joy_x, joy_y))
{
currentTargetNum++;
score++;
//if no more targets are left display the winning message
if(currentTargetNum == targetsNum)
{
if(MessageBox( NULL, TEXT("Congratulations! ")\
TEXT("You win!")\
TEXT("Do you want to play again? "),
TEXT("End of game"),
MB_YESNO | MB_TASKMODAL) == IDYES){
start = 1;
startBack = 1;
currentTargetNum = 0;
}
EndDialog(hDlg, TRUE);
}
}
SelectBrush( hDC, hbrOld );
SelectPen( hDC, hpenOld );
EndPaint( hDlg, &ps );
//ReleaseDC(hDlg, hDC);
}
Many thanks
ANDY
|
|
|
|
|
Hi,
I use a WebClient to post some data to a server. (.Net 2.0) The server returns back:
HTTP/1.1 100 Continue
Server: Microsoft-IIS/5.0
Date: …
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Content-Type: text/xml;charset=ISO-8859-1
Content-Length: 929
This is valid as per the RFC:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html[^]
As per the http specs this is a valid way of returning content and is generally used when the server requires more time to process and sends you a 100 Continue.
However from .Net I get the exception:
The server committed a protocol violation. Section=ResponseStatusLine
While processing the response. This seems to because the space in the headers is considered a possible security issue.
This is a bit of chicken and the egg. Header splitting is a security issue however 100 Continue + header splitting is valid as per the specs.
http://www.dotnet247.com/247reference/msgs/57/289086.aspx[^]
Now reading a bit more I found this nice comment on an MSDN blog:
http://blogs.msdn.com/david.wang/archive/2006/04/05/HTTP-SYS-IIS-and-the-100-continue.aspx[^]
Clients which advertise to be HTTP/1.1 compliant and then crash on "100 continue" are the real problem (they are not following public specifications)
The “fix” is to add a setting in the web config to disable the checking of split headers:
[...] httpWebRequest useUnsafeHeaderParsing="true" [...]
My problem is that Setting the flag in the config does not make any difference. Setting the flag using reflection does not help either. I still get the exception.
Setting the Enable100Continue property on the ServicePointManager or ServicePoint does not help either. I still get the exception.
Any help is welcome.
Thanks,
Corneliu.
-- modified at 19:17 Sunday 25th February, 2007
|
|
|
|
|
I am trying to strongly-name our assemblies.
We will be using dotfuscator ce, so we will use "Delay Signing".
I generated keys using SN.exe -k KeyFile.snk
I entered these lines into all our assembly files:
' Strong Name
<assembly: assemblykeyfileattribute("..\..\keyfile.snk")="">
<assembly: assemblydelaysignattribute(true)="">
Now, I keep getting this error:
Unable to emit assembly: Referenced assembly 'Interop.BIOPLUGINACTXLib' does not have a strong name
We use a 3rd-party OCX named "BioPlugInActX.ocx". When I use this OCX in my project, .NET generates interop DLLs and puts these DLLs in the project REFERENCES:
Interop.BIOPLUGINACTXLib.dll
AxInterop.BIOPLUGINACTXLib.dll
How can I use this OCX (Dlls?) in my project with strongly-named assemblies?
I did some searching, and tried using tlbimp.exe, but that seems to want a DLL (not OCX), and/or a type-library (tlb file).
I don't get it?
Any help?????????
Thanks,
-Len Miller
"If I had eight hours to chop down a tree, I'd spend six sharpening my axe."
-Abraham Lincoln
|
|
|
|
|
hi,
please if any one knows how to integrate .net framework with autocad or with 3d studio max using dll or something like that, post the reply as soon as possible.
thanks very much .
|
|
|
|
|
I had finished my project and I want give to my frien. How should I biuld my project, that it work at my friend computer (he don't have .Net framework)?
|
|
|
|
|
thesad wrote: he don't have .Net framework
Then he must install it.
|
|
|
|
|
then how create setup? I use visual studio c++ 2005 express edition.
|
|
|
|
|
Good Day to All,
I created a software for my school that allows the proffessor to instantly distribute a file or a folder to every student's terminals.
My problem is that when we tested it in our school, I get two exceptions. First is a Security Exception and a FILE IO Exception.
After much reading, I found out that there is a so-called "mscorcfg.msc" and by default, if the user is not an administrator, he won't have enough permision.
So what I did was, I configured my computer at home for a "USER" to have "FullTrust". Indicated on the mscorcfg.msc is the config file is located at "C:\Documents and Settings\<username>\Application Data\Microsoft\CLR****\V2.0****\security.config"
So My question is, Will it work if I copy the security.config from my house then manually copying it to my proffessor's terminal to get rid of the exceptions?
Thank you in advance.
|
|
|
|
|
That would unwise.
The computer your professor uses will be inside a the college or university network which has its own set of security settings. Copying settings from your home to your university will most likely have an adverse reaction on other applications that are being run.
|
|
|
|
|
Hi All,
I definition of .NET FRAMEWORK - all class object ( except int, char and ext. ) are sending to function as reference.
So in witch case i need to use ref/out in declaration of function ?
Thanks for any help.
|
|
|
|
|
Hi,
without out/ref function arguments are passed:
- by value (=the value of the thing is put on stack) for value types such as int and struct
- by reference (=the address of the object is put on stack) for reference types such as Form
with ref added, an additional indirection is used, which means when the function argument
was some variable, rather than passing the variable (as stated above) a pointer to it gets
passed, allowing the callee to modify that variable.
This allows for a method to have multiple outputs: one return value and any number of "ref"
arguments.
So you could create a method
void getThreeCoordinates(ref int x, ref int y, ref int z) {x=1; y=2; z=3;}
When called as:
int a=2, b=3, c=4;
getThreeCoordinates(ref a, ref b, ref c);
all three local variables would be changed.
A ref argument needs to have a value before it can be passed with ref; an out argument does not.
(So the example would not need initial values if out had been used).
All of this can be found in any reference manual on C# of course.
|
|
|
|
|
All this i already know.
But if (for simple example) in my program i passing only class object that are passing as reference types - then when do i need to use the ref/out ?
From what i see - in this case - if i will not use the ref/out i will have same result any way.
What i missing here ?
|
|
|
|
|
Hi,
you dont HAVE to use ref/out, but sometimes you can make good use of it.
BTW the ref/out is part of the argument list's signature used in matching method
calls and methods.
To illustrate its effect:
ArrayList list1=new ArrayList();
ArrayList list2=list1;
list1.Add("a");
list1.Add("b");
show(list1, list2);
do1(list2);
show(list1, list2);
do2(ref list2);
show(list1, list2);
...
public void do1(ArrayList list) {list.Add("c"); list=new ArrayList(); list.Add("d");}
public void do2(ref ArrayList list) {list.Add("e"); list=new ArrayList(); list.Add("f");}
with appropriate show() method will output
(a,b) (a,b)
(a,b,c) (a,b,c)
(a,b,c,e) (f)
because do2 changes the variable list2, whereas do1 does not.
|
|
|
|
|
Has anyone experienced this, or a workaround?
I am using a WebBrowser control to display an xml file from the file system. The size of the xml file is 190k. Everything is fine except when I close the control (say using a tabbed interface). When closing/removing the browser control, the application experiences a large delay (~7 secs on my machine). Internet Explorer (7) does not show this behavior; it loads up the file at the same speed (as me) and closes immediately with no delay.
Any insight would be appreciated. Here is the code I refined down to illustrate the problem.
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
<br />
TabPage page = this.tabControl1.TabPages[0];<br />
WebBrowser wb = (WebBrowser)page.Controls[0];<br />
wb.Navigate(@"D:\temp\large.xml");<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
this.tabControl1.TabPages.Remove(this.tabControl1.SelectedTab);<br />
}<br />
Michael
Developer, Author, Chef
|
|
|
|
|
Well, it seems whenever i ask a question I figure out a workaround. In this case, I am still not 100% sure why this works. And yes, the DoEvents() is necessary for this the page to close quickly (due to asnync loading I guess).
private void button1_Click(object sender, EventArgs e)<br />
{<br />
<br />
WebBrowser wb = (WebBrowser)this.tabControl1.SelectedTab.Controls[0];<br />
wb.Navigate("");<br />
Application.DoEvents();<br />
this.tabControl1.TabPages.Remove(this.tabControl1.SelectedTab);<br />
}<br />
Michael
Developer, Author, Chef
|
|
|
|
|
Hi !
I need to implement udp protocol in C#/VB.net Win Forms that send some request to the broadcast address from specific port and then change to be client and receive multiple answers from the broadcast on the same specific port.
My questions are:
1.Is the first connection should use blocking (synchronous) functions ?
2.Should I close this first socket,and then open another one on the same port in order to get the broadcast answers ?
3.In which way should I get the broadcast answers:a.using asynchronous function and events like BeginSend/EndSend etc or b.using threads ?
4.How do I get multiple answers on the same port in this case ?
I will be glad to get answers/code snippets.
Tnx
AliJ
|
|
|
|
|
Hi,
There are two properties on MailMessage object in .Net 2.0:
MailMessage.From
MailMessage.Sender
Can anyone tell me the difference between the two? Thanks!
Sindy
|
|
|
|
|