NetOfficeFw / NetOffice

🌌 Create add-ins and automation code for Microsoft Office applications.
MIT License
697 stars 143 forks source link

Statement in whats wrong in NetOffice and why i leave #241

Closed SebastianDotNet closed 4 years ago

SebastianDotNet commented 5 years ago

https://wordpress.com/view/microschuft.wordpress.com

samatstariongroup commented 5 years ago

Dear @SebastianDotNet,

I am sorry to read that you are leaving the project. Would you be able to give an opinion on what a better alternative is than NetOffice to create Office Addins, both open-source or proprietary solution tips would be appreciated.

jozefizso commented 5 years ago

Link to the actual blogpost: https://microschuft.wordpress.com/2019/04/16/finaly-block/

SRunUp commented 5 years ago

Will the project continue to be maintained?

AndreasSummer commented 5 years ago

Can you please explain the problem with the com proxy system.

jozefizso commented 4 years ago

Will the project continue to be maintained?

I try to maintain the project and release bug fixes.

Rand-Random commented 2 years ago

@jozefizso First of all thanks for trying to maintain the project and keep it alive, even going so far as to try to release a .net 6 version of it.

BUT

This issue doesn't really provide any confidence in the project when one of the lead developers ( @SebastianDotNet ) leaves the project with a statement describing a major design flaw.

Event after 3 years later and the claim an example of the issue can be provided, no exmple was given and there seems no work going on to adress this design flaw.

The design flaw seems so omni present that even @SebastianDotNet does not only further develop this project but also dropped using the project all togehter for his own work.

So I would like to ask How do you expect the average user to have confidence in using this tool, and I have happily been using it for the last ~7 years, in the current state?

Feel free to correct me if I am wrong and the issue at hand isn't as big as it seems like. In that case I would appreciate it if @SebastianDotNet or @jozefizso could explain why this issue can be neglected and the project is still safe to use.

As I stated I have happily been using the proejct and would like to continue using it, but I need to provide a confident reasoning to my higher ups that this project is still relevent and can be used.

jozefizso commented 2 years ago

Hi @Rand-Random, this is open source project provided without any warranties.

You are free to fix the design issue, any PR is welcome.

We are not forcing users to use this library. There are other options like VSTO provided directly by Microsoft.

jozefizso commented 2 years ago

@Rand-Random what you should be actually telling/answering to your manager is: Are you willing to fix bugs in open source libraries you are using?

semenenkov commented 2 years ago

Hello @jozefizso @SebastianDotNet,

I've read https://microschuft.wordpress.com/2019/04/16/finaly-block/ multiple times and not sure I understand how something can work for a small project and not be not applicable at all for the big one. Where is that limit of applicability and how it can be measured. There is an unanswered question above from @AndreasSummer Can you please explain the problem with the com proxy system. Is it caused by GC which is not 100% under our control?

From blog post: I can give an example if you want – just ask me. Can you please provide such an example. That would be very helpful to understand which use cases are applicable for this library and which are not.

@jozefizso you suggest to create PR with a fix. It seems that lot of people are using this library and probably some of them would be happy to create such kind of PR if that's possible. You know better than anyone its internals. I think there would be much more chances to get such PR if you could provide more details on this issue.

jozefizso commented 2 years ago

Hi @semenenkov, did you run into issues when using this library?

We are using these libraries in production applications and we did not run into issues which are described in the blog post.

semenenkov commented 2 years ago

Hi @jozefizso thank you for reply.

I was migrating 1 or 2 times my codebase from PIA to NetOffice. I have even reported one issue with suggestion for a fix which was accepted (it was not a PR, just few line changes I've mentioned directly in the ticket). It seems to be working, but I did not make these changes live because existing PIA logic was working as well, tested and used by many people. There was only one issue with NetOffice that it would increase my app about 5x-10x in size, I don't remember exact numbers.

My thoughts are getting back to netoffice from time to time by couple of reasons: 1) PIAs not updated, but Office object model grows, one of the recent examples is Field3 2) NetOffice seems to be more under my control than PIA, I can take source code and debug in case of some issues

Today I had another think-about-netoffice-once-a-year day because one of my clients is getting RPC_E_SERVERFAULT error from Access and I am not sure whether it is a really Access issue or some invalid usage from PIA which can be changed somehow. I came here because for the first time I've noticed that there are two repos - NetOffice and NetOfficeFw. I was not sure which one is related to original author (Sebastian), started to search for his relation and finally found this issue.

It's good that it is used in production by you and many others. But the fact that initial author has left this project, has created this issue and wrote that blog post - it is a bit disturbing. So if you could tell what did he mean, what can go wrong and why we should not care about this - that would be really great.

jozefizso commented 2 years ago

If you are getting exceptions when using PIA, there is nothing the NetOffice would help as the error comes from Office application. NetOffice is such more flexible wrapper for the API then PIA.

Actually, there is at least one API in PowerPoint which does not work with NetOffice. That is Application.HWND and other HWND members (see https://github.com/NetOfficeFw/NetOffice/issues/140).

This is a limitation of PowerPoint which does not allow to call this API using late binding and the method name. It only works when it is called directly using dispatch ID. We have a prototype which fixes this but it is a long way to have it production ready.

semenenkov commented 2 years ago

@jozefizso I think that powerpoint issue is not related to this ticket. Sorry to be intrusive. Original author has made a huge amount of work and then left the project because of some core issue. Many people just would like to know what it is and will raise this question from time to time. I think you should be aware what's wrong. I think it would make sense to explain it once. Or tell that you're not aware, once. Instead of getting such questions from time to time.

jozefizso commented 2 years ago

Or tell that you're not aware, once.

I won't be explaining claims made by others.

Many people just would like to know what it is and will raise this question from time to time.

As I said before, this is open source project provided without any warranties.

semenenkov commented 2 years ago

I won't be explaining claims made by others.

It looks strange but looks like should be enough to stop raising this. Thanks!

semenenkov commented 2 years ago

Well, I've asked the original author (Sebastian Lange) for explanations in the corresponding blog post and got the reply. For the sake of fairness I think it must be copied here. I've highlighted with bold few words which I think are good news for those who is warry about it:

You may know NetOffice wrap COM proxies and every new created proxy trough this proxy is stored in a tree to make sure we dont miss any proxy to free them. Dispose will free the proxy and all childs, child childs… and so on.

In a bigger project you share instances especially to attach an event not more than once and you may store more proxies to make sure you dont make access to the COM server multiple times when its unessecary. (increase performance a lot in some situations)

In a complex project, its very complicated to say can we dispose the stored proxy or its in use by someone or a child proxy is in use by someone, similiar issue with event triggers and its arguments btw. You can create a bypass for all these problems with code and discipline (call clone/dispose every time its needed) but this realy blows your code up and its still a possible big big error source.

Plain COM interop seems to make a good job with GC.Collect especialy in VSTO(seems its a custom clr hosting with modifications), no need to free something at hand, the runtime knows for every proxy its in use or not. As i start with NetOffice VSTO was not an option for developers targeting a wide range of MS Office. For now -and this is funny- since Microsoft lose interesst in VSTO it works like a charm with the last 5 Office versions.

And one more: For my feel 99% of developers which use NetOffice are not aware of this lifetime problem at the time i leave and this makes me worries.

Some regards to jozef 🙂

@jozefizso sorry for being annoying and thank you for supporting all this stuff.

jozefizso commented 2 years ago

Thanks a lot @semenenkov for posting Sebastian's answer here.

I can agree, the VSTO is better choice for some projects. Historically, you must install VSTO runtime and this requires administrative privileges. With NetOffice you can just deploy you app or addin for user accounts without admin rights. And this could be more beneficial for small project where you won't have memory issues with retaining COM objects.

Sebastian is right that for complex projects you must have discipline and be aware of COM memory management.

I personally prefer to use ReSharper dotMemory to validate how application is retaining objects. For example in MVVM apps which are using messenger pattern it is easy to forget to use weak references to objects and the whole messenger can blow up the memory. So this problem is not just in NetOffice.