|
You need to redefine the struct in C# and make sure the size is the same. www.pinvoke.net has examples.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I created a web program using the dropdown cascading extender from AJAX and from time to time the error message appears below for unknow reason when I choose from the dropdownlist.
You have any idea or work aorund for this problem?
--------------------------------------------------------------------------------
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Dabsukol
|
|
|
|
|
Telling the folks in the ASP.NET forum the exact error seems like a good plae to startt
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am clubbing multiple word documents into a single word document. But sometimes the document is corrupted and this stops the whole application. How to skip the corrupted doc and proceed with other documents using C#.net? Please help
Nitin Raj Bidkikar
|
|
|
|
|
Put a try { } catch { } block around the statement that is getting the error, and just ignore it (or catch the specific exception and just ignore that one).
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I added a keyboard hook by calling the SetWindowsHookEx but the delegate I was passing as a parameter for the function was being garbage collected, although the delegate was declared as a global variable. I was instantiating the delegate in a method, but, after instantiating it in the constructor of the class that contained the delegate it stopped being garbage collected and the problem was solved.
While doing some research I found Chris Brumme's blog were he Is saying that it's a better practice use a delegate and call the native method asynchronously rather than pinning the delegate that was GC in the memory. Therefore I tried this approach
public delegate IntPtr SetHookDelegate(int idHook, HookProc lpfn, IntPtr hInstance, uint threadId);
SetHookDelegate myookDelegate = null;
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
myookDelegate = new SetHookDelegate(Win32.SetWindowsHookEx);
myookDelegate.BeginInvoke((int)Win32.HookType.WH_KEYBOARD_LL,
HookProcedure,
Win32.GetModuleHandle(curModule.ModuleName),
0, new AsyncCallback(CallMeWhenFinished), myReturnValue);
}
but the callback method "CallMeWhenFinished" is called right away and the thread on which the hook was added is finished without waiting for the delegate passed as a parameter to the native function SetWindowsHookEx. Why is the thread finished right away and not listening on the callback function?
|
|
|
|
|
razvan_dme wrote: Why is the thread finished right away and not listening on the callback function?
Because async calls are non-blocking.
|
|
|
|
|
Yea, well that's an obvious answer, my question was more like, how can I overcome this
|
|
|
|
|
Hello Everybody,
i have an application which is existing on a server, i need to create a "shortcut" on a PC on the network that when clicked access that program
if someone has an idea, or a document which can help i'll be thankfull
thanks in advance
best regards
|
|
|
|
|
You need to create a shortcut, using the network path. Which bit are you stuck on ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Dear christian,
to create a shortcut i have to have permission to access the server, i can't give permission to all user to access all the server, i just want them to access just the application.
is there a way to make a shortcut programatically that run this application on the server?
thank you fo your help
|
|
|
|
|
Hello!
I'm working on C# wrapper for C library. And I got two structures:
<br />
struct params<br />
{<br />
char* info;<br />
params* next;<br />
};<br />
<br />
struct device<br />
{<br />
unsigned int flags;<br />
char* name;<br />
char* description;<br />
params* p_params;<br />
device* next;<br />
};<br />
And got 2 functions I use:
<br />
int get_device_list( device* dev );<br />
void free_device_list( device* dev );<br />
So, what I do:
<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
public class device<br />
{<br />
[MarshalAs(UnmanagedType(UnmanagedType.U4)<br />
uint flags;<br />
<br />
[MarshalAs(UnmanagedType(UnmanagedType.LPStr)<br />
string name;<br />
<br />
[MarshalAs(UnmanagedType(UnmanagedType.LPStr)<br />
string description;<br />
<br />
IntPtr p_params;<br />
IntPtr next;<br />
<br />
public device() <br />
{<br />
name = new string( '\0', 100 );<br />
description = new string( '\0', 100 );<br />
flsgs = 0;<br />
p_params = IntPtr.Zero;<br />
next = IntPtr.Zero;<br />
}<br />
<br />
}<br />
<br />
[Dllimport("api.dll")]<br />
static extern int get_device_list( IntPtr device_ptr );<br />
<br />
[Dllimport("api.dll")]<br />
static extern int free_device_list( IntPtr device_ptr );<br />
<br />
<br />
public static void main()<br />
{<br />
device dev;<br />
IntPtr device_ptr = Marshal.AllocHGlobal( Sizeof( typeof( device ) ) );<br />
Marshal.StructureToPtr( dev, device_ptr, false ) );<br />
<br />
int result = get_device_list( device_ptr );
<br />
free_device_list( device_ptr );<br />
<br />
Marshal.FreeHGlobal( device_ptr );<br />
}<br />
<br />
Actually, I can't realize why the call of the first function is successful, and the call of second one leads to exception throwing?
Help please, thanks in advance.
|
|
|
|
|
You are using it incorrectly. If a API a freeXXX method, it normally means it will allocate the memory as well.
This means you, in this case need not allocate memory. Simply pass the pointer into the function and have it filled. Then after you have finished using it, free the memory with the freeXXX function.
You are complicating things by using a class instead of a struct. As a start, go unsafe and use a C usage example to get started.
|
|
|
|
|
Hi,
I have an application that takes data from a datagrid to an Excel spreadsheet. I would like to rename the sheets (after exporting) from the default Sheet1, Sheet2, etc to my own specified name. The code that I have below gives me an error which says that:
'Property or indexer 'Microsoft.Office.Interop.Excel.Sheets.this[object]' cannot be assigned to -- it is read only'.
Is there any other way I can do this?
//create new worksheet
Microsoft.Office.Interop.Excel._Application _appClass = new ApplicationClass();
_appClass.Visible = true;
_appClass.Caption = "Exported ECS Errors";
Microsoft.Office.Interop.Excel.Workbook wbk = _appClass.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
wbk.Worksheets["Sheet1"] = "Mvelo";
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
It looks like you're trying to assign a string value to the sheet object, rather than the property which contains the name. I've not done any interop in a while so I can't remember the syntax - something like:
wbk.Worksheets["Sheet1"].Name = "Mvelo";
should work about right.
HTH
Dave
It definitely isn't definatley
|
|
|
|
|
This is the error I get when I put the '.Name' code:
wbk.WorkSheets["Sheet1"].Name = "Mvelo";
'Only assignment, call, increment, decrement, and new object expressions can be used as a statement.'
Mvelo Walaza
Developer
Telkom SA
modified on Tuesday, April 22, 2008 2:15 AM
|
|
|
|
|
hi
i have to read selected items of one list box to other listbox.and the selected item should be deleted and added to other list box.its working i had done it.
but the problem is it should not hit the server while doing such process.so we have to do the coding in javascript itseems.so plz help me in this regard.pls provide me the code in javascript.
iam clear with my question?
|
|
|
|
|
Why would you ask for javascript in the C# forum ?
I suggest reading the article I link to in my sig.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
HI, i ve written an application in dotnet c#(visual studio 2005) which requires to call a function written in c(this is part of other application). So please help me on how to call this function.
|
|
|
|
|
your C function can be called as part of a dll using P/invoke. You have an app in C, not C++ ? It works the same way, anyhow, so long as it's in a dll. To call the function within a running app, you need to use WM_COPYDATA or something to set up interprocess communication.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi, now i ve been able to call the function from the c# application. I made the dll and in the *.def file i ve exported this particular function. Then in my c# application using [dllimport(*.dll}], i called the function and i was successful in that, Now according to the c application as soon as this function is called it populates a structure with some values and ultimately i want these values. So now after successfully calling this function how can i get the structure values????Pls help
|
|
|
|
|
hi,
by trial and error method i have added many users to the DCOM object through DCOMCNFG. I want to know while hosting the website which users would require the permissions. and also keep everything secured.
thanks,
adi_nik
|
|
|
|
|
i think you only need to add ASPNET user
|
|
|
|
|
|
Hi!
I'm developing a Winform application in C# 2.0 which access to a SQL Server Express.
Currently I'm using this connection string (app.config):
connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=True"
As you can see, currently I'm using Windows Authentication to log on the SQL Server.
I want to add a user login form and depending on which user has logged in, I will grant or deny opening some of the forms which my application has.
How should I manage these users? I was thinking in having a table with (user,password) and encrypting the password in some way.
Is there a best practice to do this?
|
|
|
|