Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to read dwg file (on nuget version 1.3 or 1.4 #515

Open
enr1qo opened this issue Dec 23, 2024 · 7 comments
Open

Failed to read dwg file (on nuget version 1.3 or 1.4 #515

enr1qo opened this issue Dec 23, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@enr1qo
Copy link

enr1qo commented Dec 23, 2024

I create simple console app for read dwg files to check blocks attributes.
On nuget version 1.2 all worked excelent, but after i upgrade version to 1.3 I have exception -
system.invalidoperationexception collection was modified.
On version 1.4 i get the same error.

Version 1.2 I read 2 entities from dwg and all work fine:
Acad_sharp_v1 2

Version 1.3-1.4 i have an exception:
Acad_sharp_v1 4

But at the same time DxfReader works correctly on all versions.

@enr1qo enr1qo added the bug Something isn't working label Dec 23, 2024
@DomCR
Copy link
Owner

DomCR commented Dec 23, 2024

Hi @enr1qo,

Can you provide the file to run the example on my end?

@enr1qo
Copy link
Author

enr1qo commented Dec 23, 2024

Hi @DomCR !
Here the file.

test2.zip

@DomCR
Copy link
Owner

DomCR commented Dec 23, 2024

I think that the problem is in your code, in the last image you are using the DwgReader without disposing it, this may keep the collection busy and throws the exception when you try to access it.

Try to change the code and make it the same as the first image, or use the DwgReader like so:

	CadDocument doc;
	using (DwgReader reader = new DwgReader(_file))
	{
		doc = reader.Read();
	}

Hope this helps.

@enr1qo
Copy link
Author

enr1qo commented Dec 23, 2024

In my old project (on version 1.2) i used using and it worked fine. When i update version, i get an exception, but i think, error was in my project, then i created clear another one.

I change code, but issue still here:

Acad_sharp_v1 4_add_using

@DomCR
Copy link
Owner

DomCR commented Dec 23, 2024

Can you provide the full stack trace of the exception? translated to English please.

@enr1qo
Copy link
Author

enr1qo commented Dec 24, 2024

Hi @DomCR !
Here the stack trace:

System.InvalidOperationException
  HResult=0x80131509
  Message = Collection was modified, enumeration operation may not execute.
  Source = mscorlib
  Stack trace:
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
   at ACadSharp.IO.Templates.BlockVisibilityParameterTemplate.Build(CadDocumentBuilder builder)
   at ACadSharp.IO.CadDocumentBuilder.BuildDocument()
   at ACadSharp.IO.DWG.DwgDocumentBuilder.BuildDocument()
   at ACadSharp.IO.DwgReader.Read()
   at AcadSharpTest_new.Program.Main(String[] args) in C:\dev\AcadSharpTest_new\Program.cs:line 18

@DomCR
Copy link
Owner

DomCR commented Dec 24, 2024

The BlockVisibilityParameterTemplate has a bug when working with a dictionary, the issue is related to a limitation of NetFramework, I'll open a PR to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants