|
Hi,
I am trying to create a word 2003 document thru a windows application written in C#. I have added a reference of the Microsoft Word 11.0 Object library to my project.
Thing is that the below line of code is causing an error "The type or namespace name 'Word' could not be found (are you missing a using directive or an assembly reference?)"
private Word.ApplicationClass WordApp = new Word.ApplicationClass();
This is the main line where the Word document creation starts. I dont get this error when using Microsoft Word 9.0 Object library (Word 2000).. but the requirement is for Word 2003 automation.
I am not using Visual Tools for Office 2003. Is there any other way to create word 2003 documents?
Thanks in advance
sundancer
|
|
|
|
|
You should always use the PIAs (Primary Interop Assemblies) for Office when possible. Visual Tools for Office 2003 (.NET programming support comes on the Office 2003 Professional CD) and the downloadable Office XP PIAs are what you should use. In fact, if you want to support both Office XP and 2003, use the Office XP PIAs which you can download from MSDN[^]. Typelibs are typically forward-compatible but not always backward compatible. In fact, for most basic functionality even typelibs from Office 97 should support 97, 2000, XP (2002) and 2003 versions of Office products.
In any case, though, the problem is that you aren't referencing the namespace correctly. The namespace is not simply "Word". It's most likely "Microsoft.Office.Interop.Word". At the top of your source file along with all the other using statements, type using then hit Alt+J to display the namespaces.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i recently downloaded the source code for the WinConsole, by Wesner Moise. (http://www.codeproject.com/csharp/winconsole.asp). I have the source codes, but i'm not sure how to compile them.
at the command line, i've tried different ways:
csc WinConsole.cs
csc /t:library WinConsole.cs
csc /r:ConsoleWriter.cs WinConsole.cs
all i get is errors like "no entry point defined" and "ERROR CS0246: The type or namespace name 'ConsoleWriter' could not be found (are you missing a using directive or an assembly reference?)"
i'm not sure what to do. in the folder i downloaded with all the sources, i have the following files:
bin (dir)
obj (dir)
App (icon)
AssemblyInfo.cs
ConsoleWriter.cs
Main.cs
WinConsole.cs
WinConsole.csproj
WinConsole.csproj.user
Can someone help me?
|
|
|
|
|
It looks like the download contains essentially two parts: the WinConsole class and the ConsoleWriter helper class to help redirect trace output, which are implemented in WinConsole.cs and ConsoleWriter.cs respectively, and a test program implemented in Main.cs with assembly data in AssemblyInfo.cs .
To build the test program, either use Visual Studio to open the WinConsole.csproj , or build on the command line like so:
csc /t:winexe /win32icon:app.ico assemblyinfo.cs ConsoleWriter.cs Main.cs WinConsole.cs To use in your own application, you can either include the source files in your project, or you could build WinConsole as a DLL:
csc /t:library /out:WinConsole.dll WinConsole.cs ConsoleWriter.cs
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
i get it now. thank you very much.
i didnt know about the icon feature. nice
thanks,
ip
|
|
|
|
|
Hi,
im just start designing a new WinForms app, and i'm not sure if the .NET built-in data binding via DataView etc. is the right tool for the job.
The application will read and write its data from/to an XML file (multiple versions must be supported, at least for reading).
The XML structure is not very "relational", it is more a document (in the sense of a Word document) than a database (tablular data).
I'm coming from the Java world, and used a ValueModel style data binding with great success. More details about the ValueModel data binding style can be found at http://c2.com/ppr/vmodels.html and http://c2.com/cgi/wiki?ModelViewControllerHistory.
With a ValueModel data binding, i would read the XML File in an object, put that in a ValueHolder, and would wire all widgets with AspectAdapters, SelectionInList, ...
This would provide me with a bi-directional binding, and usinge the BufferedValueHolder i would even get a buffering for free.
My question to the WinForms gurus:
- is the DataView data binding flexible enough, even if my data is more a document than a table?
- can i bind a text field bi-directional to a property of an arbitrary object?
- does the DataView data binding work when the widgets are on different forms?
- what's hard with DataView data binding, what style of binding requirements should be avoided?
Bye,
Jürgen
|
|
|
|
|
zet wrote:
is the DataView data binding flexible enough, even if my data is more a document than a table?
No, it is not. A DataView is created over a DataTable , which is a class used within a DataSet (any of which don't require you to use a DataView , but they will be more limited in functionality since the DataView supports filtering, sorting, etc.). A DataSet XML schema consists of 2- to 3-level elements (tabular data, as you said).
zet wrote:
can i bind a text field bi-directional to a property of an arbitrary object?
Yes; see the PropertyManager class in the .NET Framework SDK for more information. This is used in the same manner as the CurrencyManager class, which are both derivatices of the BindingManagerBase which is used by the Control.BindingContext property. Use the Control.DataBindings collection property to add bindings to objects (like another TextBox ) for properties (like the Text property of your two TextBox es).
zet wrote:
does the DataView data binding work when the widgets are on different forms?
A DataView is simply a class. So long as the instance is accessible on different forms, the controls can bind to them. The import thing to realize is that a BindingContext must bind to the exact same object and member name (like a DataSet and one of its table names, or just the DataTable itself).
--
There is nothing really provided in the .NET BCL (base class library) that provides the sort of binding you're asking for, but that's not to say it isn't possible (anything is possible when comparing Java and .NET, it's just that the JRE contains/lacks some stuff that .NET doesn't/does have).
This also sounds quite a bit like the MVC pattern (Model-View-Controller), or at least it would fit. CodeProject has several good articles about MVC, including Declarative Programming Of The MVC Pattern Within The Context Of DataBinding[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a project that was written in VB6 and which I need to re-design in C#. It uses a number of MSHFlexGrids that have had the header height expanded to fit two lines of text. Is there a grid control available in C# that will allow me to change the header width?
|
|
|
|
|
Not in the base class library (BCL), no. The DataGrid is the closest thing to the FlexGrid component, but does not expose APIs for owner-drawing the headers.
I suggest you take a look at some third-part controls like XtraGrid[^]. Many other third-party controls are available to use, but I've used this one and it works well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This is really starting to piss me off. Someone please prove me wrong.
Here is a link to the function in DX 9 sdk.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3dx/functions/texture/d3dxsavesurfacetofile.asp
Following dll's are referenced in my program.
Microsoft.DirectX.dll
Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll
The code:
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
.
.
//here trying to call D3DXSaveSurfaceToFile
//the parameters are wrong but thats not the problem
D3DXSaveSurfaceToFile();
The eror I get: "The name does not exist in MainFrom..." bla bla
In other words, I cannot locate the function. Where is it?
Please help.
If it helps, here is the link to what I am trying to do. The only problem the link is in C++.
http://www.codeproject.com/dialog/screencap.asp#And%20The%20DirectX%20way%20of%20doing%20it%20:
Thanks in advance.
|
|
|
|
|
Nick Z wrote:
Someone please prove me wrong.
Look at the .NET docs, no point looking at the C++ docs. There.
top secret xacc-ide 0.0.1
|
|
|
|
|
You can't just use a C/C++ function name in managed code. You need to P/Invoke it. Besides, C# doesn't even support functions - only methods (functions defined on classes). Looking at the Managed Languages documentation for DirectX 9.0 may help.
For example, the SurfaceLoader has a method, Save , which is what you want. This saves a surface to a file for various different image formats.
Remember that C# is a true object-oriented language (.NET code can contain functions, but the C# language does not support it).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I ended up locating the SurfaceLoader.Save function in the Direct3DX.xml file that came with the dll.
I learned the hard not to look inside DirectX C++ documentation, when programing in managed code.
Thanks for taking the time to answer.
And here is the newsgroup thread that has some more info on what I was doing and the outcome.
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&safe=off&threadm=_fUFc.8819%24kz.1831472%40news4.srv.hcvlny.cv.net&rnum=1&prev=/groups%3Fq%3Dd3dxsavesurfacetofile%26hl%3Den%26lr%3D%26ie%3DUTF-8%26safe%3Doff%26selm%3D_fUFc.8819%2524kz.1831472%2540news4.srv.hcvlny.cv.net%26rnum%3D1
|
|
|
|
|
am making a Windows service application using the C# .Net framework.
I have installed the setup and when I try to start my service from the Services in the Administrative tools in control panel, I get the following error:
JIT Debugging failed with the following error: Access is denied.
JIT Debugging was initiated by the user account 'NT AUTHORITY\LOCAL SERVICE'.
Please give me any clues how to debug the JIT error.
Thank you.
|
|
|
|
|
You need to grant the NT AUTHORITY\LOCAL SERVICE user debug privileges. That's actually a very bad idea, though. Anyone with debugging privileges can do quite a few things to your system that would go unchecked (like overwriting memory addresses without taking advantage of security holes). Instead, while debugging your service you should run it as you (which, presumably, already has debugging privileges).
To give NT AUTHORITY\LOCAL SERVICE debugging privileges or to make sure you have them (if you can debug, you have them), use the local security policy editor in Control Panel->Administrative Tools->Local Security Policy. Drill down to Local Policies->User Rights Assignment. Note that if you're in a domain, the domain administrator might have set these and taken away your ability to change them.
Again, giving NT AUTHORITY\LOCAL SERVICE debug privileges is a bad idea - it is a security hole. Just change the login credentials for your service to you for the time being to find the problem. Do run it as NT AUTHORITY\LOCAL SERVICE to make sure everything works once yo've figured out the problem, however.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi guys!
..eeeh only this, i can't run a c# app on a pc with win 2k but without .NET framework installed.
why this... ?
can i do something?
thanx!!
PD: sorry my english is so bad
|
|
|
|
|
jl_araya wrote:
can i do something?
Sure, you can. Install the framework.
jl_araya wrote:
why this... ?
Roughly spoken, your C# app contains no machine code and needs the Common Language Runtime which is part of the framework to execute.
I think you should read a bit in MSDN[^].
|
|
|
|
|
.Net IL simply put are instructions that no hardware processor will understand on its own. How do you expect it to run on a machine that has no idea how to handle it?
|
|
|
|
|
thanks, now i understand.
bye!
|
|
|
|
|
I'm writing a class and and app to test the class. My hope is that when I'm done, the class will be portable, and I can reuse it in other projects. I also want to learn the proper structure on how to do this.
In the Form in my main app, I have set a textBox that I want to use as feedback to the user on the processing that is done in the class. What is the best way to pass strings back to the form textbox from the class?
I tried to use an event, but couldn't quite make it work. Is this the correct way to go about this?
I also tried a public string that appeneded to the textbox in the set. it gave me some error about object reference.
Since I will be writing to the log at various points in the class, I think it should be a simple one line statement.
Any hints?
|
|
|
|
|
If you are talking about unit testing your class then I strongly recommend you check out nUnit http://www.nunit.org/[^]. This is a ready made tool for testing, and means that you won't need to put together a WinForms test harness. All you need to do is create an new testing assembly that calls in to your class and then nUnit picks it up. There is a quick start tutorial that comes with it that is really easy to follow.
There are lots of additional testing strategies that you can employ. One of the easiest is to use Debug.Assert statements throughout your code, especially in UI code which I find particularly hard to test. These debugging commands are stripped out in the release version of the code so they won't impact on the performance of production code, but for development they can show up problems quickly.
Does this help? Or have I just thrown your test strategy into confusion?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
I really haven't gotten into serious testing yet.
I'm just asking for the best practice for sending a string from a class back to the form that called the instance of the class.
My case is where I have a form with a text box, and I create an instance of a class to do some processing on an input file. I would like to send feedback and debug info back to the form to be displayed in a textbox.
How can I do that cleanly without having to explicitly know what object in the form I'm sending the data to?
Is an event the way to do this?
Thanks.
|
|
|
|
|
pidhead wrote:
My case is where I have a form with a text box, and I create an instance of a class to do some processing on an input file. I would like to send feedback and debug info back to the form to be displayed in a textbox.
I'm not sure that is really the best way to test the class. Even if you are not into "serious testing yet". Take a look at some of the classes available in the System.Diagnostics namespace and you'll find a number of features of .NET that help you test your code.
You can use Debug.WriteLine to send information to the OutputWindow in VS.NET which will provide a much more efficient solution, especially as you seem to want to get information out from within the class's code, rather than just checking return values.
I still recommend taking a look at nUnit because it does what you are trying to achieve in a more structured way. Also, it allows you to selectively choose which tests to run or you can run the tests over the whole system so you can check if any recent changes broke other code elsewhere you didn't expect to be affected (I common occurrance for all developers, and even more so if you are new to programming).
To get back to what you actually asked for:
pidhead wrote:
How can I do that cleanly without having to explicitly know what object in the form I'm sending the data to?
Is an event the way to do this?
You already knew the answer as your second question answers your first. Yes, you can use an event in this senario. But remember you won't be sending information directly to the object in the form, but to an event handling method that will receive the event and that will alter the control for you. After all, the TextBox or whatever knows nothing of your event.
Finally, (sorry, I'm going to get back on my writing-clean-code-for-the-situation-is-the-most-important-thing hobby-horse again) do you really want to load up your class with events that are only used for testing. What will happen to all these events being fired when you're done with testing? Okay, so they won't go anywhere but they will slow the code down, and encasing them in #ifdef #endif blocks so that you omit them when not testing is going to make the code almost unreadable.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Dear Sir and Madam
After I close MemoryStream, how to open it to read again?
MemoryStream m = new MemoryStream();
. . .
. . .
m.Close
How to open it to do the following?
m.Seek(0, SeekOrigin.Begin);
Thank You.
Sorry for bad English.
|
|
|
|
|
A memorystream is like a marriage; once you have closed the door on it, there is no going back.
my blog
|
|
|
|
|