René's URL Explorer Experiment


Title: BinaryFormatter deprecation issue while using PythonEngine.Shutdown() · Issue #2469 · pythonnet/pythonnet · GitHub

Open Graph Title: BinaryFormatter deprecation issue while using PythonEngine.Shutdown() · Issue #2469 · pythonnet/pythonnet

X Title: BinaryFormatter deprecation issue while using PythonEngine.Shutdown() · Issue #2469 · pythonnet/pythonnet

Description: Environment Pythonnet version: 3.0.4 Python version: 3.11 Operating System: Windows 10 .NET Runtime: .NET8/netstandard 2.0 Details Hi, I am facing a known issue with PythonEngine.Shutdown() that should have been solved. I saw looking aro...

Open Graph Description: Environment Pythonnet version: 3.0.4 Python version: 3.11 Operating System: Windows 10 .NET Runtime: .NET8/netstandard 2.0 Details Hi, I am facing a known issue with PythonEngine.Shutdown() that sh...

X Description: Environment Pythonnet version: 3.0.4 Python version: 3.11 Operating System: Windows 10 .NET Runtime: .NET8/netstandard 2.0 Details Hi, I am facing a known issue with PythonEngine.Shutdown() that sh...

Opengraph URL: https://github.com/pythonnet/pythonnet/issues/2469

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"BinaryFormatter deprecation issue while using PythonEngine.Shutdown()","articleBody":"### Environment\r\n\r\n-   Pythonnet version: 3.0.4\r\n-   Python version: 3.11\r\n-   Operating System: Windows 10\r\n-   .NET Runtime: .NET8/netstandard 2.0\r\n\r\n### Details\r\n\r\nHi, I am facing a known issue with PythonEngine.Shutdown() that should have been solved. I saw looking around here that many others have had a problem while using the Shutdown function since it caused an exception due to the deprecation of BinaryFormatter in .NET8. \r\nHere the exception I am getting:\r\n\r\nSystem.NotSupportedException: 'BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information.'\r\n\r\nI am aware of the workarounds already provided such as the management of \"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization\" parameter, if I manually manage this set the issue is not presenting anymore, but it seems to me that is more of a patch than a fix.\r\n\r\nSince .NET9 will totally get rid of BinaryFormatter, and since I read in other threads that this issue should have been fixed, I was wondering if I was missing something or if the only way to manage this is by manually managing the serialization parameter.\r\n\r\nHere follows the code I am using (in a project that targets netstandard2.0, while it is called by a .NET8 project). \r\n\r\n```csharp\r\nusing Python.Runtime;\r\nusing System;\r\nusing System.IO;\r\n\r\nnamespace ExecutePython\r\n{\r\n    public class Class1\r\n    {\r\n        string filePath;\r\n        \r\n        public Class1(string FilePath) \r\n        { \r\n            filePath = FilePath;\r\n            Initialize();\r\n        }\r\n\r\n        public void Initialize()\r\n        {\r\n            string pythonDll = @\"C:\\Users\\MyUser\\AppData\\Local\\Programs\\Python\\Python311\\python311.dll\";\r\n            Environment.SetEnvironmentVariable(\"PYTHONNET_PYDLL\", pythonDll);\r\n            PythonEngine.Initialize();\r\n        }\r\n        public void ExecutePython()\r\n        {\r\n            string pyCode = File.ReadAllText(filePath);\r\n\r\n            using (Py.GIL())\r\n            {\r\n                try\r\n                {\r\n                    PythonEngine.Exec(pyCode);\r\n                }\r\n                catch (Exception ex)\r\n                {\r\n                    //log error\r\n                }\r\n            }\r\n            \r\n            try\r\n            {\r\n                //AppContext.SetSwitch(\"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization\", true);\r\n                PythonEngine.Shutdown();  \r\n                //AppContext.SetSwitch(\"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization\", false);\r\n            }\r\n            catch (Exception e)\r\n            { }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThe code that is executing correctly in my python script is a sample code, in my case it just pops up a window to see that the script is executing correctly","author":{"url":"https://github.com/Kaz8939","@type":"Person","name":"Kaz8939"},"datePublished":"2024-10-01T09:58:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/2469/pythonnet/issues/2469"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:04641ab8-4e9f-b0d7-8537-c88533361f85
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEB90:2735DF:101EA4:16AF03:6970A071
html-safe-nonce1fe727ca1b50048b5aedba6d0056bd35d9d3da0cddd912aa8cbab2bf34d2edaf
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjkwOjI3MzVERjoxMDFFQTQ6MTZBRjAzOjY5NzBBMDcxIiwidmlzaXRvcl9pZCI6IjM0MzYwNDg5NjYxMzY5MzA0MTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac00ce4502008a7c538d6c05ab3226536ea874dfd8e30dce8e1c536ef35f09148c
hovercard-subject-tagissue:2558753669
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/2469/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b0a7f684eedfaa427250367b48ff017cfab39217d74559f3fd4b01dcf79b5aa4/pythonnet/pythonnet/issues/2469
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b0a7f684eedfaa427250367b48ff017cfab39217d74559f3fd4b01dcf79b5aa4/pythonnet/pythonnet/issues/2469
og:image:altEnvironment Pythonnet version: 3.0.4 Python version: 3.11 Operating System: Windows 10 .NET Runtime: .NET8/netstandard 2.0 Details Hi, I am facing a known issue with PythonEngine.Shutdown() that sh...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKaz8939
hostnamegithub.com
expected-hostnamegithub.com
Noneb06a4c45c45fd0bb038b3759265ea6e38211f45d18130bc65261990be6b5972a
turbo-cache-controlno-preview
go-importgithub.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git
octolytics-dimension-user_id6050430
octolytics-dimension-user_loginpythonnet
octolytics-dimension-repository_id14748123
octolytics-dimension-repository_nwopythonnet/pythonnet
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14748123
octolytics-dimension-repository_network_root_nwopythonnet/pythonnet
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release0e1c4964831785bd64cb22d82e7cf2391ae01f45
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/pythonnet/pythonnet/issues/2469#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F2469
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpythonnet%2Fpythonnet%2Fissues%2F2469
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=pythonnet%2Fpythonnet
Reloadhttps://github.com/pythonnet/pythonnet/issues/2469
Reloadhttps://github.com/pythonnet/pythonnet/issues/2469
Reloadhttps://github.com/pythonnet/pythonnet/issues/2469
pythonnet https://github.com/pythonnet
pythonnethttps://github.com/pythonnet/pythonnet
Notifications https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Fork 770 https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Star 5.4k https://github.com/login?return_to=%2Fpythonnet%2Fpythonnet
Code https://github.com/pythonnet/pythonnet
Issues 155 https://github.com/pythonnet/pythonnet/issues
Pull requests 18 https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects 0 https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/pythonnet/pythonnet/security
Please reload this pagehttps://github.com/pythonnet/pythonnet/issues/2469
Insights https://github.com/pythonnet/pythonnet/pulse
Code https://github.com/pythonnet/pythonnet
Issues https://github.com/pythonnet/pythonnet/issues
Pull requests https://github.com/pythonnet/pythonnet/pulls
Discussions https://github.com/pythonnet/pythonnet/discussions
Actions https://github.com/pythonnet/pythonnet/actions
Projects https://github.com/pythonnet/pythonnet/projects
Wiki https://github.com/pythonnet/pythonnet/wiki
Security https://github.com/pythonnet/pythonnet/security
Insights https://github.com/pythonnet/pythonnet/pulse
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/2469
New issuehttps://github.com/login?return_to=https://github.com/pythonnet/pythonnet/issues/2469
BinaryFormatter deprecation issue while using PythonEngine.Shutdown()https://github.com/pythonnet/pythonnet/issues/2469#top
bughttps://github.com/pythonnet/pythonnet/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/Kaz8939
https://github.com/Kaz8939
Kaz8939https://github.com/Kaz8939
on Oct 1, 2024https://github.com/pythonnet/pythonnet/issues/2469#issue-2558753669
https://aka.ms/binaryformatterhttps://aka.ms/binaryformatter
bughttps://github.com/pythonnet/pythonnet/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.