[GH-ISSUE #32] trying to sign dll "Operation is not valid due to the current state of the object" #30

Closed
opened 2026-02-25 21:30:30 +03:00 by kerem · 24 comments
Owner

Originally created by @den-run-ai on GitHub (Feb 16, 2017).
Original GitHub issue: https://github.com/brutaldev/StrongNameSigner/issues/32

I'm trying to sign Python.Runtime.DLL, but got this error:

image

This used to work before and stopped working in version 1.8.0.

Originally created by @den-run-ai on GitHub (Feb 16, 2017). Original GitHub issue: https://github.com/brutaldev/StrongNameSigner/issues/32 I'm trying to sign Python.Runtime.DLL, but got this error: ![image](https://cloud.githubusercontent.com/assets/7870949/23033454/c2500910-f43d-11e6-973f-0ba957f08c49.png) This used to work before and stopped working in version 1.8.0.
kerem 2026-02-25 21:30:30 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@brutaldev commented on GitHub (Feb 16, 2017):

The latest version is 2.1.0 which has some significant changes to the signing. If it still breaks with the latest version let me know, I'm not supporting version 1.x.

<!-- gh-comment-id:280406945 --> @brutaldev commented on GitHub (Feb 16, 2017): The latest version is [2.1.0](https://github.com/brutaldev/StrongNameSigner/releases/tag/v2.1.0) which has some significant changes to the signing. If it still breaks with the latest version let me know, I'm not supporting version 1.x.
Author
Owner

@den-run-ai commented on GitHub (Feb 16, 2017):

@brutaldev yes, I checked with latest as well

<!-- gh-comment-id:280407452 --> @den-run-ai commented on GitHub (Feb 16, 2017): @brutaldev yes, I checked with latest as well
Author
Owner

@den-run-ai commented on GitHub (Feb 16, 2017):

@brutaldev actually not, let me check

<!-- gh-comment-id:280407789 --> @den-run-ai commented on GitHub (Feb 16, 2017): @brutaldev actually not, let me check
Author
Owner

@den-run-ai commented on GitHub (Feb 16, 2017):

2.1.0.0 still not working:

image

<!-- gh-comment-id:280408103 --> @den-run-ai commented on GitHub (Feb 16, 2017): 2.1.0.0 still not working: ![image](https://cloud.githubusercontent.com/assets/7870949/23033864/4c1a1978-f43f-11e6-8fb9-91e1ec839d5e.png)
Author
Owner

@brutaldev commented on GitHub (Feb 16, 2017):

Please post a link to where I can get Python.Runtime.DLL to test on my side.

<!-- gh-comment-id:280408391 --> @brutaldev commented on GitHub (Feb 16, 2017): Please post a link to where I can get `Python.Runtime.DLL` to test on my side.
Author
Owner

@den-run-ai commented on GitHub (Feb 16, 2017):

I just recompiled from master with Debug/AnyCPU and your tool is working!

image

<!-- gh-comment-id:280410158 --> @den-run-ai commented on GitHub (Feb 16, 2017): I just recompiled from master with Debug/AnyCPU and your tool is working! ![image](https://cloud.githubusercontent.com/assets/7870949/23034086/2f2bb1e0-f440-11e6-97ec-fb8eec590ae1.png)
Author
Owner

@den-run-ai commented on GitHub (Feb 16, 2017):

you can download Python.Runtime.DLL from here, just extract .whl as zip files:

https://pypi.python.org/pypi/pythonnet/2.2.2#downloads

<!-- gh-comment-id:280410500 --> @den-run-ai commented on GitHub (Feb 16, 2017): you can download Python.Runtime.DLL from here, just extract .whl as zip files: https://pypi.python.org/pypi/pythonnet/2.2.2#downloads
Author
Owner

@brutaldev commented on GitHub (Feb 16, 2017):

Hmm, could just be a messes up release then. I'll drop 2.1.1 just as a rebuild and see if that helps. I'll let you know when it's up and you can give it another test with the official version.

<!-- gh-comment-id:280410901 --> @brutaldev commented on GitHub (Feb 16, 2017): Hmm, could just be a messes up release then. I'll drop 2.1.1 just as a rebuild and see if that helps. I'll let you know when it's up and you can give it another test with the official version.
Author
Owner

@brutaldev commented on GitHub (Feb 16, 2017):

Give this version a try please: https://brutaldev.com/download/StrongNameSigner_Setup.exe?v=2.1.1

<!-- gh-comment-id:280413527 --> @brutaldev commented on GitHub (Feb 16, 2017): Give this version a try please: [https://brutaldev.com/download/StrongNameSigner_Setup.exe?v=2.1.1](https://brutaldev.com/download/StrongNameSigner_Setup.exe?v=2.1.1)
Author
Owner

@den-run-ai commented on GitHub (Feb 16, 2017):

still the same error, so try downloading my DLL.

<!-- gh-comment-id:280431691 --> @den-run-ai commented on GitHub (Feb 16, 2017): still the same error, so try downloading my DLL.
Author
Owner

@brutaldev commented on GitHub (Feb 16, 2017):

So strange, I can the Python.Runtime.DLL using 2.1.0 and 2.1.1 without any error. Try build in release and see if it happens on your side.

<!-- gh-comment-id:280432632 --> @brutaldev commented on GitHub (Feb 16, 2017): So strange, I can the `Python.Runtime.DLL` using 2.1.0 and 2.1.1 without any error. Try build in release and see if it happens on your side.
Author
Owner

@den-run-ai commented on GitHub (Feb 16, 2017):

I can't build release version, it complains about sandcastle.

On Thu, Feb 16, 2017, 1:27 PM Werner van Deventer notifications@github.com
wrote:

So strange, I can the Python.Runtime.DLL using 2.1.0 and 2.1.1 without
any error. Try build in release and see if it happens on your side.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/brutaldev/StrongNameSigner/issues/32#issuecomment-280432632,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHgZ5VHObI8JnvUz2UTGBpPRjOnPfuUKks5rdKMEgaJpZM4MDVmO
.

<!-- gh-comment-id:280434195 --> @den-run-ai commented on GitHub (Feb 16, 2017): I can't build release version, it complains about sandcastle. On Thu, Feb 16, 2017, 1:27 PM Werner van Deventer <notifications@github.com> wrote: > So strange, I can the Python.Runtime.DLL using 2.1.0 and 2.1.1 without > any error. Try build in release and see if it happens on your side. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/brutaldev/StrongNameSigner/issues/32#issuecomment-280432632>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AHgZ5VHObI8JnvUz2UTGBpPRjOnPfuUKks5rdKMEgaJpZM4MDVmO> > . >
Author
Owner

@brutaldev commented on GitHub (Feb 16, 2017):

That will be a post build step anyway, you will still have a release build to run before that happens.

<!-- gh-comment-id:280435075 --> @brutaldev commented on GitHub (Feb 16, 2017): That will be a post build step anyway, you will still have a release build to run before that happens.
Author
Owner

@den-run-ai commented on GitHub (Feb 16, 2017):

Release build from Master branch works as well.

<!-- gh-comment-id:280436331 --> @den-run-ai commented on GitHub (Feb 16, 2017): Release build from Master branch works as well.
Author
Owner

@brutaldev commented on GitHub (Feb 16, 2017):

¯\(ツ)
Only seems to break on your machine. I've tried signing Python.Runtime.DLL on several machines now and cannot reproduce the error even on the current version of 2.1.0.

<!-- gh-comment-id:280440366 --> @brutaldev commented on GitHub (Feb 16, 2017): ¯\\_(ツ)_/¯ Only seems to break on your machine. I've tried signing `Python.Runtime.DLL` on several machines now and cannot reproduce the error even on the current version of 2.1.0.
Author
Owner

@den-run-ai commented on GitHub (Feb 16, 2017):

@brutaldev I just tried on another machine and this works with the latest installer. so me too:

¯(ツ)/¯

<!-- gh-comment-id:280486429 --> @den-run-ai commented on GitHub (Feb 16, 2017): @brutaldev I just tried on another machine and this works with the latest installer. so me too: ¯\(ツ)/¯
Author
Owner

@brutaldev commented on GitHub (Feb 17, 2017):

I think we can chalk this up to a weird bug that only exists on your machine with compiled release versions... If anyone else gets the "Operation is not valid due to the current state of the object" error then just re-open this issue.

<!-- gh-comment-id:280716900 --> @brutaldev commented on GitHub (Feb 17, 2017): I think we can chalk this up to a weird bug that only exists on your machine with compiled release versions... If anyone else gets the "_Operation is not valid due to the current state of the object_" error then just re-open this issue.
Author
Owner

@den-run-ai commented on GitHub (Mar 8, 2017):

@brutaldev I just reproduced this problem on Windows 10 (before it was Windows 7). I'm using 64-bit Python 3.5 wheel:

https://pypi.python.org/packages/c2/1b/616ba08a2856537f511e052020dc2317213af031d88c8db361f26cc89f6a/pythonnet-2.2.2-cp35-cp35m-win_amd64.whl

<!-- gh-comment-id:284929755 --> @den-run-ai commented on GitHub (Mar 8, 2017): @brutaldev I just reproduced this problem on Windows 10 (before it was Windows 7). I'm using 64-bit Python 3.5 wheel: https://pypi.python.org/packages/c2/1b/616ba08a2856537f511e052020dc2317213af031d88c8db361f26cc89f6a/pythonnet-2.2.2-cp35-cp35m-win_amd64.whl
Author
Owner

@brutaldev commented on GitHub (Mar 8, 2017):

@denfromufa Are you talking about Python.Runtime.dll? Just tried your download link on my machine and works without a hitch. Only seems to happen for you... If you can get it to happen consistently in the UI, click the "Show Output" link and see if there is a stack trace there which might be useful.

<!-- gh-comment-id:285116607 --> @brutaldev commented on GitHub (Mar 8, 2017): @denfromufa Are you talking about `Python.Runtime.dll`? Just tried your download link on my machine and works without a hitch. Only seems to happen for you... If you can get it to happen consistently in the UI, click the "Show Output" link and see if there is a stack trace there which might be useful.
Author
Owner

@GieltjE commented on GitHub (Jul 10, 2017):

This is easily fixable by releasing the AssemblyDefinition (just call .Dispose or put it in a using) and just caching the AssemblyInfo results (Don't foget to fix the SignAssembly too!).

After these two simple patches everyting works like a charm!

Took me about 3 minutes to figure out, let's just get this crap over with.

<!-- gh-comment-id:314124532 --> @GieltjE commented on GitHub (Jul 10, 2017): This is easily fixable by releasing the AssemblyDefinition (just call .Dispose or put it in a using) and just caching the AssemblyInfo results (Don't foget to fix the SignAssembly too!). After these two simple patches everyting works like a charm! Took me about 3 minutes to figure out, let's just get this crap over with.
Author
Owner

@brutaldev commented on GitHub (Jul 10, 2017):

@GieltjE I updated to the latest pre-release of Mono.Cecil which has IDisposable on AssemblyDefinition. Also ensured they are disposed of at appropriate times but the file locking problem with the pre-release version still remains as I mentioned in issue #40. You can verify with the unit tests that file locks still occur so I won't be going live with this version. You can view the changes in the mono.cecil-0.10 branch.

Caching AssemblyInfo would be pointless since only the getter generates an instance of that class and it gets stale really fast, it would fail with the same problem long before it gets there because it still needs to read the PDB files in long before that.

Would love to see how you easily fixed this in about 3 minutes, perhaps you can provide a PR for your changes and you can get this crap over with yourself.

<!-- gh-comment-id:314224400 --> @brutaldev commented on GitHub (Jul 10, 2017): @GieltjE I updated to the latest pre-release of Mono.Cecil which has `IDisposable` on `AssemblyDefinition`. Also ensured they are disposed of at appropriate times but the file locking problem with the pre-release version still remains as I mentioned in issue #40. You can verify with the [unit tests](https://ci.appveyor.com/project/brutaldev/strongnamesigner) that file locks still occur so I won't be going live with this version. You can view the changes in the [mono.cecil-0.10 branch](https://github.com/brutaldev/StrongNameSigner/tree/mono.cecil-0.10). Caching `AssemblyInfo` would be pointless since only the getter generates an instance of that class and it gets stale really fast, it would fail with the same problem long before it gets there because it still needs to read the PDB files in long before that. Would love to see how you easily fixed this in about 3 minutes, perhaps you can provide a PR for your changes and you can get this crap over with yourself.
Author
Owner

@GieltjE commented on GitHub (Jul 10, 2017):

Works for me, just took the parts I needed, updated the assembly info to hold the hash (switched to .net sha1) to rectify the list<string,list< and properly disposed the objects both in the getassembly and signassembly.

Everthing runs fine, no more locking issues.

Could try to patch up your source if you like.

<!-- gh-comment-id:314228681 --> @GieltjE commented on GitHub (Jul 10, 2017): Works for me, just took the parts I needed, updated the assembly info to hold the hash (switched to .net sha1) to rectify the list<string,list< and properly disposed the objects both in the getassembly and signassembly. Everthing runs fine, no more locking issues. Could try to patch up your source if you like.
Author
Owner

@GieltjE commented on GitHub (Aug 23, 2017):

https://github.com/nunit/nunit3-vs-adapter/issues/325

That is the bug that prohibits the correct functioning of the test cases, otherwise with the proper disposal of the mentioned objects the new versions are perfectly fine :)

<!-- gh-comment-id:324249668 --> @GieltjE commented on GitHub (Aug 23, 2017): https://github.com/nunit/nunit3-vs-adapter/issues/325 That is the bug that prohibits the correct functioning of the test cases, otherwise with the proper disposal of the mentioned objects the new versions are perfectly fine :)
Author
Owner

@brutaldev commented on GitHub (Aug 23, 2017):

The following commit contains the changes you are referring to: github.com/brutaldev/StrongNameSigner@9cb11ec8e7

This commit properly disposes these objects and uses the beta6 version of Mono.Cecil. This may fix the PDB issue, but the new version of Mono.Cecil holds locks to files so any non-trivial signing process will fail. This is clearly highlighted by the failing tests when introducing these changes: https://ci.appveyor.com/project/brutaldev/strongnamesigner/build/tests

Although the changes you mention will fix the problem in your very simple signing process, this is not a viable solution because of the additional problems it introduces and how many other users will experience file locking issues.

<!-- gh-comment-id:324259693 --> @brutaldev commented on GitHub (Aug 23, 2017): The following commit contains the changes you are referring to: https://github.com/brutaldev/StrongNameSigner/commit/9cb11ec8e77074f3e36207ebcd85095e109cdb7e This commit properly disposes these objects and uses the beta6 version of Mono.Cecil. This may fix the PDB issue, but the new version of Mono.Cecil holds locks to files so any non-trivial signing process will fail. This is clearly highlighted by the failing tests when introducing these changes: https://ci.appveyor.com/project/brutaldev/strongnamesigner/build/tests Although the changes you mention will fix the problem in your very simple signing process, this is not a viable solution because of the additional problems it introduces and how many other users will experience file locking issues.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/StrongNameSigner#30
No description provided.