Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all 1741 articles
Browse latest View live

New Post: StackOverflow Exception When Creating new Excel.Application

$
0
0
This is driving me crazy, not sure what I'm missing.

This line of code within an assembly I'm building (a plugin for Act!) causes Act! to crash and throws a StackOverflow exception when I attach to Act! to debug it.

Project is set for x86, .NET 4.0

I can do this no problem with a new Windows Form application, and a colleague has used NetOffice with Excel (same line of code) for another Act! plugin no problem.

Any ideas what I might be missing?

Thanks in advance!
Len

Created Unassigned: Download is not working [21347]

$
0
0
I was only able to download it from:
[https://github.com/CaioProiete/NetOffice-NuGet](https://github.com/CaioProiete/NetOffice-NuGet)

Please fix the download, it freeze at around 29MB, then timeout.

New Post: StackOverflow Exception When Creating new Excel.Application

$
0
0
hey man!

I need some code(exception strack trace) to pin point the problem. (no reported bugs like this in NetOffice so far)

the common understanding problem is: you try to access the host application and start a new one.(check your taskmanager for excel.exe if the problem occours)

for my feel: its a vb.net plugin, right???

Another fast option is to send me your solution to public.sebastian[at]web.de (Remove any other private code if you want) In this case i can reproduce the problem and give you an answer very feasy(fast and easy)

*Sebastian

Commented Unassigned: Download is not working [21347]

$
0
0
I was only able to download it from:
[https://github.com/CaioProiete/NetOffice-NuGet](https://github.com/CaioProiete/NetOffice-NuGet)

Please fix the download, it freeze at around 29MB, then timeout.
Comments: ** Comment from web user: SebastianDotNet **

hey man![0A][0A]i support the NO downloads from codeplex only.[0A]first timer i ever heard from NetOffice on github (WTF?)[0A]you can download NetOffice from various websites but[0A]these downloads are not official in exception of codeplex.[0A] [0A]A generaly hint: Use when ever you can the original downloads from the[0A]contributer/manufactor. Its more safety. (Use a search engine to find the real contributor)[0A][0A]*Sebastian[0A][0A]

Commented Unassigned: An extra "CodeBase" registry value for COM Addin [21224]

$
0
0
When I use NetOffice to creates an Excel COM Addin whose assembly version is not 1.0.0.0 and register it using RegAsm.exe with /codebase option, an extra "CodeBase" registry value is created under a (non-exisitng) assembly version 1.0.0.0. When unregistering it using RegAsm /unregister, the registry entries for the version 1.0.0.0 is left unremoved in the registry.

RegAsm creates a set of correct registry entries for the Assembly's correct version, as well as an extra entry for 1.0.0.0, so the registered COM Addin works. Also, unremoved registry entries do nothing critical (except for slightly wasting the registry.) So, this is a relatively minor issue.

REPRODUCTION STEPS

1. Run NetOffice Developer Toolbox, choose VS Project Wizard, then create an Automation Addin project for Excel. (Leave other options as their default.)
2. Open the generated project with Visual Studio.
3. Open the property page for MyAssembly project, choose Application tab, click on Assembly Information..., then change the Assembly version to, say, 1.2.3.4.
4. On Build tab, uncheck "Register for COM interop" so that VS doesn't update the registry.
5. Build the solution to create MyAssembly.dll.
6. Open an Administrator Command Prompt, cd to the directory where MyAssembly.dll resides, and run regasm MyAssembly.dll /codebase
7. Run RegEdit and examine the entries below the COM Addin's CLSID.

OBSERVED BEHAVIOUR

Below the InprocServer32 registry key, I see two subkeys: 1.0.0.0 and 1.2.3.4. Below 1.0.0.0 there is a registry value "CodeBase". (Registry values below 1.2.3.4 are fine, BTW.)

See the attached .reg file for details. Lines 18 and 19 are unwanted. (I'm on 64 bit Windows and developing a 32 bit addin, so the registry keys are below Wow6432Node.)

EXPECTED BEHAVIOUR

Below the InprocServer32 registry key, I see only one subkey 1.2.3.4.

GUESSED CAUSE

NetOffice.ExcelApi.Tools.COMAddin.RegisterFunction(Type) contains a code to add a "CodeBase", which I suspect is misbehaving. (Although I'm not sure it is really the cause of the issue nor what is the intended purpose of the code...)

ENVIRONMENT

Windows 7 (64 bit), .NET Framework 4.0, Visual Studio 2013 Express, NetOffice 1.6, Toolbox 1.2.
Comments: ** Comment from web user: SebastianDotNet **

sry for the delay. (i do NetOffice in my free time)[0A][0A]It's true, the toolbox does some mistakes for the reg code.[0A]Thx for pointing this out. I suggest you to use NO 1.7 and start from the examples.[0A]The next toolbox version comes with NO 1.8 (and includes a visual ribbon designer and its totaly new developed)[0A][0A]BTW: It looks like you have much experience and you are an expert developer. for this reason, please contact me in my private skype account if you want: public.sebastian . give me a hint to this discussion in your contact agreement(otherwise, its ignored).[0A][0A]*Sebastian

New Post: Few errors in VS Express and SharpDevelop

$
0
0
hey niknah,

i can't show you the right direction so far because i dont use SharpDevelop.
Not sure but SharpDevelop shows you a COM Rerference dialog arent' so`?
(In Visual Studio, this is a special tab)
Otherwise try a file search for "extensibility.dll" and don't be scared if its multiple exits.
use the first entry you found so far.

*Sebastian

New Post: StackOverflow Exception When Creating new Excel.Application

$
0
0
It doesn't give me an exception stack trace, but here is the code I'm using, which is pretty basic:

NetOffice.ExcelApi.Application excelApp = new NetOffice.ExcelApi.Application();
NetOffice.ExcelApi.Workbook book;
NetOffice.ExcelApi.Worksheet sheet;

Strangely, this works fine on two different development machines my colleague uses, and on two of mine it exhibits this problem.

We ran it on another computer, and got yet a different message "Worksheet not found in loaded NetOffice Assemblies".

Any ideas?

Thanks,
Len

New Post: Read .pst or .ost file

$
0
0
Hi guys!

I am also looking for RemoveStore() method. Did you find something?

With regards, Viljem

New Post: How not dispose of child objects?

$
0
0
I want to create my own custom collection of Word objects, but I don't know how to do this without have these objects disposed when the parent COM collection is disposed.

For example, something like this:


GenericCollection<NetOffice.WordApi.Bookmarks> customCollection = new GenericCollection<NetOffice.WordApi.Bookmarks>();

using (NetOffice.WordApi.Bookmarks bookmarks = application.ActiveDocument.Bookmarks)
{
// if bookmark meets some special criteria add to my own collection
foreach (NetOffice.WordApi.Bookmark bookmark in bookmarks) customCollection.Add(bookmark);
}



At the end of the using statement, all child bookmarks in my custom collection are automatically disposed.

How can I only dispose of the parent "bookmarks" collection object, but keep the children alive in my custom collection until I am done using them? (eventually I will call "customCollection.Dispose()" to dispose of my custom collection and bookmarks)

Thank you for any advice!

New Post: How not dispose of child objects?

$
0
0
Not sure i'm understand this. Your bookmark is still alive in Office, just the local proxy is destroyed.
Create a new proxy if you want. (application.ActiveDocument.Bookmarks[i]) (otherwise, may this is a scenario the NO proxy-wrapper class is just create local, aren't so?)

In NO 1.7 (available in the download section) you can disable the com proxy management (temporaily) if you want:

bool NetOffice.Settings.Default.EnableProxyManagement{get; set;}

Be careful with these option!
*Sebastian

New Post: StackOverflow Exception When Creating new Excel.Application

$
0
0
"Worksheet not found in loaded NetOffice Assemblies"
Sounds like a reference problem. NO cant' find the loaded ExcelApi.dll in the current AppDomain. I need to know your NetOffice version and operating system version to reproduce the problem. (op-system in test and failed prod system) BTW: make sure the solution is not loaded from a network ressource(forbidden in .NET default policies)

I see, your example code is not real, its impossible that Workbook works fine and Worksheet cause trouble. (BTW the compiler removes unused variables and the NO types are never adressed/analyzed/called. I need your (nearly)real scenario to find a solution for you. otherwise i only can point you the right direction (based on I/O prinicple)

*
Sebastian

Troubleshooting/Analyze Hint: Disable other extensions/addins on your problem-child system. This helps to identify the problem.

New Post: debugging NetOffice.ExcelApi.Worksheet in VS2010 causes Outlook Wizard to start

$
0
0
I know this problem. This is an MS Office-problem.
Some years ago, i face the problem first time n VB6(in the debugger!!!!) while i try to analyze a collection in the watch window.
Not sure why but Outlook is started. NO idea why....

Anyway, this problem is regardless from any API. Its just a scary MS-behaviour. (Your outlook is not configurated and f*cking wizard dialog is shown)
I cant't change the office implementation ;)

*Sebastian

New Post: How not dispose of child objects?

$
0
0
Thank you for the reply, Sebastian.

Let me try to explain this more clearly. Let's assume I want to create a method that returns collection of all bookmarks that start with a specified prefix. Using NetOffice, this method could like something like this:


private List<NetOffice.WordApi.Bookmark> GetBookmarksWithPrefix(NetOffice.WordApi.Document doc, string prefix)
{
List<NetOffice.WordApi.Bookmark> bookmarkList = new List<NetOffice.WordApi.Bookmark>();

using (NetOffice.WordApi.Bookmarks bookmarks = doc.Bookmarks)
    foreach (NetOffice.WordApi.Bookmark bookmark in bookmarks)
        if (bookmark.Name.StartsWith(prefix)) bookmarkList.Add(bookmark);

return bookmarkList;
}


Obviously, this won't work as expected, because when the "using" statement disposes "bookmarks", then all child bookmark objects in the bookmarkList collection will de disposed too.

So how do I either not dispose of child objects ("bookmark") when the parent is disposed ("bookmarks"), or how do I clone/copy a child object such that the clone/copy is not disposed when the original child object is disposed?
Create a new proxy if you want. (application.ActiveDocument.Bookmarks[i])
Although I understand this suggestion (create a new proxy) will work, for performance purposes this doesn't seem like the ideal solution. If I have a document with 10,000 bookmarks, I assume using this approach (re-fetching the bookmark just to create a new proxy) is not ideal. Rather, I would think either not disposing the original proxy or creating a clone/copy of the proxy would perform better.

Thank you for your ideas and your contributions to NetOffice.

New Post: StackOverflow Exception When Creating new Excel.Application

$
0
0
Just sent the source to your address.

Will check the difference in specs between OS's and report back.

Thanks for your help thus far.

Len

Reviewed: NetOffice 1.6.0 (sep 30, 2014)

$
0
0
Rated 5 Stars (out of 5) - Had some minor semantic to change when converting, but intellisense cleared it right up. Very usefull

New Post: How not dispose of child objects?

$
0
0
You have another option:
using (NetOffice.WordApi.Bookmarks bookmarks = doc.Bookmarks)
{
     foreach (NetOffice.WordApi.Bookmark bookmark in bookmarks)
     {
          if (bookmark.Name.StartsWith(prefix))
         {
               bookmarkList.Add(bookmark);
               
               // remove bookmark proxy from its parent
               bookmark.Parent.RemoveChildObject(bookmark);

              // now you have to make sure dispose is called for the bookmark at hand
              // otherwise you can re-add the bookmark (as child) to another proxy instance
              // in this case doc for example:
              doc.AddChildObject(bookmark);
         }
     }
}
*Sebastian

New Post: Outlook, attach inline image from local resource.

$
0
0
Hello everyone.

I am using C# with VS 2013. I have some images saved as resources (MyProject.Properties.Resources.SomeImage, as a System.Drawing.Bitmap), for email template generation. I was wondering if it was possible to add these images to a MailItem without having to save them to a temporary file on my computer, then upload the file again into an attachment (giving its path), then delete the temporary file once the email has been sent.

Is it possible to use base64 encoding, and reference it with a cid or something similar?

Could somebody post a short (2-3 line) code example?

I've been struggling with this all day, any help would be greatly appreciated.

New Post: Outlook, attach inline image from local resource.

$
0
0
you want to use an image to a contact/mail item?

let me know what you try do so far(in code) to pin point the problem
please explain in detail what do you want. change the image for a contact? just add a attachmen for a mailt. its not clearly for me. please help me to help you.
i need an error message and code, this is my begin... "works not" is not helpful for me.

*sebastian

New Post: Outlook, attach inline image from local resource.

$
0
0
Hi Sebastian,

Sorry if I wasn't very clear. What I want to do is really simple.

I have a System.Drawing.Bitmap object. I want to attach it to a MailItem, and set its content id to some value.

Example of what I would like to do is something like this:
// I have a variable called img that is of type System.Drawing.Bitmap

var att = mailItem.Attachments.Add( /* Add img here somehow? */);
att.SetSomeProperty("someId"); // Set the cid of att somehow?
mailItem.HTMLBody = "<img src='cid:someId' />";
I'm not getting a specific error, I just have no idea how to do this. Can I attach a System.Net.Mail.LinkedResource, or a Stream somehow?

I hope this clarifies what I'm trying to do.

Thanks for taking the time to answer my question. :)

New Post: EMBEDDING NETOFFICE IN WPF

$
0
0
Hello,

How can I embedd NetOffice in a WPF project. I would like use a canvas or a user control for view word document.

Thank you.
Gabriele
Viewing all 1741 articles
Browse latest View live




Latest Images