|
|
thank's man but can u send me more example???
I try it but all that example are for net 2003 i need it for 2005 pleas help???
-- modified at 10:03 Wednesday 17th May, 2006
|
|
|
|
|
hi,
I am trying to to client side word automation through ASP.NET, C# web based application. Server side word automation can be done easily and i have written the code, so i am able to generate the word document on the server. As per the requirement it has to be generated on the client machine. For this code should be written in some scripting language. Please help!
Thanks,
Avanika
|
|
|
|
|
Hi. I'm trying to use p/invoke on some standard C library. The library defines a struct:
<br />
typedef struct {<br />
FLAC__FrameHeader header;<br />
FLAC__Subframe subframes[8];<br />
FLAC__FrameFooter footer;<br />
} FLAC__Frame;<br />
where FLAC__FrameHeader, FLAC__Subframe, and FLAC__FrameFooter are other copmlex structures.
The library declares a function that consumes a FLAC__Frame as argument, such as :
void someFunc(FLAC__Frame frame);
[These are snippets from libFlac, for those in the know, but this is not really relevant; see here for more on FLAC.]
The question is: how do you marshall the struct to pass it back and forth between C# code and the C library function ?
I've tried to describe the FLAC_Frame structure as this, among other things:
<br />
[StructLayout(LayoutKind.Sequential)]<br />
internal struct Frame {<br />
public FrameHeader Header;<br />
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]<br />
public Subframe[] Subframes;<br />
public FrameFooter Footer;<br />
}<br />
<br />
[DllImport("libFlac.dll")]<br />
private static extern void someFunc(Frame frame);<br />
but I keep getting a TypeLoadException with the comment "Cannot marshal field 'Subframes' of type 'Frame': There is no marshaling support for this type."
It does not seem to like the array of Subframes embedded in the Frame structure.
Anybody would have hints ?
Thanks,
Pyt.
|
|
|
|
|
|
Yes, indeed. Sorry if this wasn't clear.
Subframe is a struct containing other structs (there are actually several levels of nested structs).
Pyt.
|
|
|
|
|
I was thinking, the exception thrown probably has inner exceptions, that might give you more detail. Failing that, try Marshal.SizeOf() on the SubFrame, if u get a number back and no exception, then it should work.
Finally failing that, you can define 8 structs in a 'row' perhaps.
|
|
|
|
|
Well, there was no inner exceptions. I finally put the 8 structures in a row, and it worked. Not very handy, but it'll do the trick for now. Thanks.
Pyt.
|
|
|
|
|
Hi,
I'm converting char[] to double using
Dlength = System.Convert.ToDouble(strdata);
But its throwing exception called "Unable to cast object of type 'System.char[]' to type 'System.IConvertible'.
Any idea?
|
|
|
|
|
Assuming that the char[] contains something like { '9', '.', '2', '5' } then you should convert the array into a string, then pass that into the ToDouble method.
Josh
|
|
|
|
|
<br />
char []ch = {'1','2','3','.','2','3'};<br />
String str = new String(ch);<br />
Console.WriteLine(Convert.ToDouble(str));<br />
Hope this would solve the problem.
Saqib
|
|
|
|
|
I have a sequence of 8-9 non ADO.Net operations needs to be done as a transaction. All of these should happen together or none of them. Is there any transaction support in C# for non ADO.Net operations?? If not what would be the best way to code this situation.
|
|
|
|
|
If you are using .NET 2.0 there is the System.Transaction namespace. Otherwise, you could use COM+.
|
|
|
|
|
I have a gridview on a webform. The table with the data I want it to display has a column with contents like: "Item1 Item2 Item3". What I want to do is make each one of these items appear on a new line in the cell that they are in. How would I do this?
eg.
Some Column
------------------------------
| Item1 |
| Item2 |
| Item3 |
| ... |
|___________________|___________
| |
| |
| |
| |
Thanks for any help
|
|
|
|
|
Well, have you tried to format the text of the cell as : "Item1\r\nItem2\r\nItem3\r\n"?
|
|
|
|
|
Ohh yes sorry I forgot to mention I used \r\n and Environment.NewLine (which is pretty much the same thing) with no luck.
|
|
|
|
|
Try inserting <BR> tags instead of newlines. That might do the trick.
Josh
|
|
|
|
|
Good spot (especially since its in the wrong forum)
|
|
|
|
|
Hello,
What is the procedure for printing any file (Ms Word, PDF etc) using shell within C# ?
Thanks
|
|
|
|
|
Hello, I've taken following code -as it is- from the MSDN documentation, just for the consistency, otherwise the problem is simple. For more information search in the index for "Process.StartInfo". Here you go:
void PrintDoc()
{
Process myProcess = new Process();
try
{
// Get the path that stores user documents.
string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc";
myProcess.StartInfo.Verb = "Print";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Check the path.");
}
else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
// Note that if your word processor might generate exceptions
// such as this, which are handled first.
Console.WriteLine(e.Message +
". You do not have permission to print this file.");
}
}
}
I Hope it will work for you.
|
|
|
|
|
Thanks a lot for your time. I am grateful to you.
|
|
|
|
|
Hi,
I am using this procedure successfully, but this procedure is always promting Print Dialogue (Select Pinter Option etc), Do you know how can I print directly without showing this prompt. May be there is some extra word I must use int he Verb = "print" , right ? but I dont know details.
thanks
Emran
|
|
|
|
|
Invisible printing using shell?? It's a bit of an odd combination. I don't think it's possible, and it will be variant from a file extension to the other as each program may have this "invisible printing" - supposing it actually exists in any program at all-, while other programs may not support it!!
You see, printing using shell is just launching the program associated with this file extention with the parameter "print". Usually the program will ask for more information - Printer, quality, Color/B&W, & so on-, that's why it shows the dialogue.
I'll dig up for more info, but -I'm sorry- I can't promise you anything. If you want to print few known popular document types -like you said yourself, pds MS Word-, why don't you put it in your program as a component, and print it using the component if possible? (just an idea )
|
|
|
|
|
Hello,
I appreciate your response.
I am just willing to print HTML files invisibly. And I did not understand about putting that in my program as component. Would you please explain me about component printing. (specially for HTML files).
Thanks
Emran
|
|
|
|
|
Well, it's quite simple. For eaxmple if you wish to print HTML pages whether online or on your computer. you implement a WebBrowser component (Whether visible = true, or false, it doesn't matter). Then you use:
webBrowser1.Print();
You don't need to make it visible as I said. you can put it there invisible just for printing, or you can use its full capabilities.
to change the URL use the Navigate() method.
but it's IMPORTANT to make sure that all default print setting are valid. For example make sure that your current printer is connected, On, and set as default, or you may end up printing that page using adobe virtual pdf printer, or even printing it to a file (according to your default printing settings). Also default Color options (Color - Grey Scale - B&W) are used without a choice. That's how you print invisibly;
I hope this was useful... Good Luck.
|
|
|
|