Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8776359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:02:06+00:00 2026-06-13T19:02:06+00:00

I am having trouble releasing Excel Interop Com Objects which is causing my c#

  • 0

I am having trouble releasing Excel Interop Com Objects which is causing my c# application to crash when I attempt to save and then close an Excel workbook created via Excel Interop. I feel the issue is that in some cases I am using ‘2 dots’ with excel interop COM objects which from what I’ve read is not allowed. I have eliminated 2 dots from most lines of code, but I am having troulbe figuring out a way to recreate the following lines of code so that they only use one dot. If anyone has any suggestions I would greatly appreciate it.

workbook = (Excel.Workbook)app.Workbooks.Open(startForm.excelFileLocation,);

workbook = (Excel.Workbook)app.Workbooks.Add(1);

workSheet_range.Font.Color = System.Drawing.Color.FloralWhite.ToArgb();

workSheet_range.Font.Bold = font;

workSheet_range.Interior.Color = System.Drawing.Color.Red.ToArgb();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:02:08+00:00Added an answer on June 13, 2026 at 7:02 pm

    Using two dots is not “disallowed” but it certainly can have performance impacts, especially when running in a tight loop.

    Each “dot” is a COM call to the Excel library, which can be significantly slower than normal CLR object access. In general, you want to reduce the number of COM calls to as few as possible.

    Reducing from two dots to one by splitting into two lines is not going to have any impact unless you reuse the same variable. For example, changing

    workSheet_range.Interior.Color = System.Drawing.Color.Red.ToArgb();
    

    to

    var interior = workSheet_range.Interior;
    interior.Color = System.Drawing.Color.Red.ToArgb();
    

    will have ZERO impact on performance, and may even be “optimized” back to the original single-liner if you don’t re-use the interior variable.

    However, changing

    var font = workSheet_range.Font;
    font.Color = System.Drawing.Color.FloralWhite.ToArgb();
    font.Bold = font;
    

    will have one fewer call to workSheet_range.Font so you’ll see an incremental benefit.

    BOTTOM LINE

    I wouldn’t be too concerned about changing every two-dot call but instead use a good profiling tool to determine where your code is spending the most time, then tackle that area first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble deploying a Silverlight5 application. I'm releasing to a Windows server
I'm using a UINavigationController and I'm having trouble releasing objects when I push a
I'm having troubles releasing objects.. To explain it better I have included my code
I am having trouble releasing tempArray below... tempArray is a leak and I have
I am having trouble reloading the tabs in a tab bar and then having
I'm having trouble describing this issue, which is probably why I can't find the
I have a scenario, which is seemingly simple on paper, but I'm having trouble
I'm having some trouble with my unit tests in a Spring MVC application. In
We are having trouble with a memory leak that happens only when the application
I'm working on implementing come business logic in my C# application. I'm having trouble

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.