|
Are you sure the path exists that you want to code? You should use File.Exists() before attaching it to be sure. Passing a string you typed and a string that you got from another call are not different to the application and the CLR whatsoever! Seriously - the CLR sees the same thing - it's a System.String .
Also, this doesn't use Outlook, but a simple SMTP mailer. If you use Outlook, you open a can of worms because then you must start interoping a lot of things, thereby bloating the application. You must also make sure that the user has a specific version of Outlook on their system, or make sure your app can handle different Outlook and Office API versions. If all you need to do is send mail, just stick with the simple SMTP mailer.
If you still want the Outlook functionality in your app, the .NET Framework SDK has several examples with Word and MSDN has many examples in VB.NET and C# (primarily VB.NET, unfortunately, but remember that all languages targeting the CLR use the SAME class library so most stuff is the same - just syntax is different).
-----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-----
|
|
|
|
|
Is there an easy way to determine which radio button in a group has been chosen, besides having to put code in the checkchanged or clicked event for each button in the group...???
thanks,
vince
|
|
|
|
|
Like in HTML? No, unfortunately. But it doesn't have to be difficult at all. The radio buttons must be in some container, be that any given Control or, typically, a GroupBox . In order for controls to show up in the UI, they must be added to the container's Controls collection. Use that to your advantage:
foreach (Control c in this.Controls)
{
RadioButton rb = c as RadioButton;
if (rb != null && rb.Checked)
{
Console.WriteLine("You selected {0}!", rb.Text);
break;
}
}
-----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-----
|
|
|
|
|
I need to make an application that reads from popular GIS file formats like ESRI Shape File or MapInfo TAB.
I found the open source GeoTools.net but they apparently don't work and the website on sourceforge is not really being updated.
Is there any open source or free library out there for use with .NET?
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
Has any one had much luck with this.
I have run AXIMP ont the .OCX to create the DLL. Then i have registerd the DLL using REGASM.
I add a reference to the DLL, then try to instantiate an object, I get the following error
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: Catastrophic failure
Has anyone any ideas.
I have also tried this by just adding a reference to the original .ocx, and letting the IDE to the AXIMP for me. Same problem.
Thanks
|
|
|
|
|
Big Trev wrote:
I have run AXIMP ont the .OCX to create the DLL. Then i have registerd the DLL using REGASM.
These two actions are doing the opposite.
If you intend to use an ActiveX control in your C# code, then use the IDE, Toolbox \ customize, and browse your ActiveX component. The ActiveX component will be preinteroped, so you don't need any manual call to aximp.exe
(this works in most cases. There are gotcha though).
When you drop the component into a form, you'll see whether it gets instantiated or not.
RSS feed
|
|
|
|
|
As Stephane said, just use the "Add Reference..." and select the COM tab. You almost have the right idea, though.
Use aximp.exe to import an ActiveX control and create an interop assembly. DO NOT, however, register it! Regasm.exe is for registering assemblies that contain interop metadata, such as controls that act as ActiveX controls through a CCW (COM-Callable Wrapper). If you use Regasm.exe on the interop assembly generated by from the native ActiveX control, you've just overwritten the registry settings so that the interop assembly is now the target of the CLSID! Any application trying to instantiate your original ActiveX control is now instantiating (unknowingly in almost all cases) the control in the .NET assembly through a CCW. The interop assembly, however, is looking for the actual control and not finding it because it's finding itself!
Now, I would hope (and don't remember off the top of my head) that regasm.exe checks to see if the assembly was imported from an ActiveX control. But it if isn't, you need to use "regasm.exe /u myassembly.dll" immediately, and then use "regsvr32.exe myactivex.ocx" to fix the registry problems that are most likely affecting you.
-----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-----
|
|
|
|
|
Thanks for the reply. I still can not get it working though.
this is the code i am using to create the object.
COMMSOCXLib.CommsOCXClass comm = new COMMSOCXLib.CommsOCXClass();
try
{
comm.Reset();
}
catch (System.Runtime.InteropServices.COMException e)
{
Console.WriteLine(e.ToString());
Console.ReadLine();
}
And this is the error i catch.
System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFla
gs flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at COMMSOCXLib.CommsOCXClass.Reset()
|
|
|
|
|
Did you unregister your interop assembly and re-register the actual ActiveX OCX? You might also re-install ActiveX control if it was packed in an installer, since the install might have written more registry entries. It seems as if the actual COM method (remember, the interop assembly is only a Runtime Callable Wrapper (RCW), in which calls are forwarded) is not being called because the forwarding method can't the object to call.
-----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-----
|
|
|
|
|
Yep, i did a regasm /u on the interop assembly, and regsvr32 on the ocx.
Still no joy.
let me know if you fancy having a go with the ocx. I can mail it. it is only 100k.
At the moment i an writing a DLL wrapper for the c api that also comes with the product.
Thanks
Trev
|
|
|
|
|
Hi all!
OK, so now I know how to use Office Primary Interop Assemblies to do Word automation, i.e. open a word document in its own window, maximize this window, toggle full screen mode, etc.
The question is: is it possible to load the document into the client area of a windows form? You know, if you open Microsoft Office documents in Internet Explorer they load into the explorer window, not into a blank window. Is this possible with Windows Forms / C#? If so, how?
Other - less important questions:
1) Is it possible to hide the caption (using automation) of the Microsoft Word when in full screen mode? The WordViewer doesn't show the caption in full screen mode, but the Word itself does.
2) Is it possible to force the Microsoft Word window to be always on top of other windows (again, using automation?)
3) Is it possible to use the Microsoft Word Viewer in a similar way? Whem I tried to browse the type libraries using oleview.exe I could find "Microsoft Word 9.0 Object Library", is there a type library for Word viewer?
Thanks in advance, any clues are highly appreciated!
Rado
|
|
|
|
|
Radoslav Bielik wrote:
Is this possible with Windows Forms / C#? If so, how?
Active Documents (formerly known as OLE documents) are supposed to be supported in Whidbey (VS.NET 2004).
In the mean time, you could host the web browser in a form and ask it to show that Word document.
RSS feed
|
|
|
|
|
Thanks for the information!
I will try that.
Rado
|
|
|
|
|
Does anyone know how to add a progress bar to one of the panels of a status bar? I'm referring to a windows application of course. I'm stuck and I can't find anything on the code project about this.
Thanks
|
|
|
|
|
You use owner-drawing to place or draw a ProgressBar into a StatusBar or StatusBarPanel . It's not difficult, and if you search the message threads you'll find many examples posted in the past.
-----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-----
|
|
|
|
|
hi,
i need to put a string into byte[]. i can't find any "smarter" method to do.
currently, i do it in this way. suppose string like this "at+cmgl=4"
byte[] data = {(byte) 'a', (byte) 't', .... ,(byte) '4');
as i can't convert char[] to byte[], that's why i need to it in this way.
so, any better method to do it?
thanks,
jim
|
|
|
|
|
System.Text.Encoding.GetEncoding("ENCODING TYPE).GetBytes(mystring)
Cheers,
Venkatraman Kalyanam
Bangalore - India
"Being Excellent is not a skill, it is an attitude"
Reality is an illusion caused by caffeine deficiency(one Microsoft Research scholor)
|
|
|
|
|
Or even simpler:
System.Text.Encoding.ASCII.GetBytes(mystring) or
System.Text.Encoding.Unicode.GetBytes(mystring) . There are several other encodings you can use. Not only is it easier to type, but it also eliminates partial human error in case your forget an "I" in "ASCII" or something. This also results in faster calls within the CLR since parsing strings is extremely slow, and lookups would have to be performed before you got the actual Encoding object.
-----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-----
|
|
|
|
|
Hi,
Is it possible to extract the first day of a given week (an integer) from a given year??? I've managed to get the number of the week after a severe struggle with the DateTime class & DateTimeFormatInfo class, but could not find anything about getting the dates in that week...
Thanks...
|
|
|
|
|
I take it you are using the ISO definition of a week number? (That is, a week starts on a Monday and week 1 is the week that contains the first Thursday of the year.)
To calculate the date of the Monday for a given week number, you need to calculate the date of the Monday for week 1 and then add (7 * (weeknumber-1)) days to that date.
The easiest way to do that is to calculate the date of the first Thursday and then subtract 3 days.
To calculate the date of the first Thursday, calculate the day of the week for 1-Jan for that year. If it is a: Monday, add 3 days; Tuesday, add 2; Wednesday, add 1; Thursday, you got it in one; Friday, add 6; Saturday, add 5; Sunday, add 4.
So, amalgamating all that: calc DOW for 1-Jan. For each possibility, the Monday of week 1 will therefore be
If 1-Jan is a Monday, the Monday of week 1 is 1-Jan
If 1-Jan is a Tuesday, the Monday of week 1 is 31-Dec of previous year.
If 1-Jan is a Wednesday, the Monday of week 1 is 30-Dec of previous year.
If 1-Jan is a Thursday, the Monday of week 1 is 29-Dec of previous year.
If 1-Jan is a Friday, the Monday of week 1 is 4-Jan.
If 1-Jan is a Saturday, the Monday of week 1 is 3-Jan.
If 1-Jan is a Sunday, the Monday of week 1 is 2-Jan.
So, at that point it's simple. Good luck!
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
That did the job! Thanks a lot!
Kaloyan
|
|
|
|
|
what happened to DateTime.DayOfWeek?
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Just to let you know I wrote a web article on calculating ISO week numbers:
http://www.boyet.com/Articles/PublishedArticles/CalculatingtheISOweeknumb.html
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
What's different between System.ComponentModel.Component and System.Windows.Forms.Control? When will me use the Component but not the Control in design?
Thanks.
Game is power!
|
|
|
|
|
If you looked at the documentation, you'd see that a Component (or other IComponent implementation) is anything that can be contained with in a container, or more specifically IContainer . The biggest difference? A Control is graphical and has concepts such as location and size, where a Component isn't necessarily graphical.
Take the FileSystemWatcher for example. It obviously has no UI associated with it since it just watches files and uses Win32/NT-based APIs. It does, however, have an icon associated with it in design-time. This is because it's a component and can be dragged and dropped onto the design surface. This allows code monkeys to click on it and set properties and event handlers using VS.NET (or any other emerging designer these days). You can, of course, forget about the whole component architecture and type it manually, but this allows the component to be "designed".
So, when should you use a control and when should you use a component? If you plan on displaying any UI, you must inherit from control since only controls in the parent's Controls collection are displayed - and it only takes a Control or a child class of it.
If you want your "object" to be tied to a designer (even extending the designer with your own ComponentDesigner ), you can make it derive from Component . .NET has several examples, such as the FileSystemWatcher , the EventLog , and many, many more. Just go to the overview documentation for the Component class and click on "Derived Classes" toward the top of the page.
-----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-----
|
|
|
|
|