-
Notifications
You must be signed in to change notification settings - Fork 749
NullReferenceException
with 3.0.0rc4
#1884
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
Comments
Thank you for testing out the Release Candidate. You can attach a (.NET) debugger to the running Python process and see where exactly the exception is raised, without a stack trace or a reproducible example of some sort we won't be able to help you. |
I should have noted, everything I'm doing is from python and I'm working in VS Code. .NET is not my specialty, so I'll need some help on that debugging step. I took a look through some of the documentation on the wiki and it didn't look like it was relevant, requiring Visual Studio proper. Can you help point me in the right direction? |
I have never tried to debug (apart from classic |
I'd really like to fix this one before releasing the final 3.0, but there is really not much to go on here. Can you create a reproducible example for this case? |
I spent a little time working to get debugging set up with Visual Studio yesterday and didn't have much success getting the debugger attached. With little success, I approached the problem from a slightly different direction... I noted in the OP that I have a module set up to act as a wrapper around the .NET functionality to try and create a clear delineation between Python and .NET. Rather than use the wrapper, I opted to use the "regular" code: import os
import sys
from pathlib import Path
import pandas as pd
# Add to PATH
dllPath = Path(r'C:\Program Files\Energy Exemplar\PLEXOS 9.0 API')
sys.path.append(str(dllPath))
import clr
clr.setPreload(True)
clr.AddReference('EEUTILITY')
import EEUTILITY.Enums # type: ignore
clr.AddReference('PLEXOS_NET.Core')
import PLEXOS_NET.Core as PLEXOS # type: ignore
clr.AddReference('EnergyExemplar.PLEXOS.Utility')
import EnergyExemplar.PLEXOS.Utility.Enums # type: ignore
sol = PLEXOS.Solution()
sol.Connection("Model Test Solution.zip")
sol.QueryToCSV(
'test.csv',
False,
EEUTILITY.Enums.SimulationPhaseEnum.STSchedule,
EEUTILITY.Enums.CollectionEnum.SystemRegions,
'',
'',
EnergyExemplar.PLEXOS.Utility.Enums.PeriodEnum.FiscalYear,
EnergyExemplar.PLEXOS.Utility.Enums.SeriesTypeEnum.Statistics,
'29', # USE,
None,
None,
'',
'',
'',
EnergyExemplar.PLEXOS.Utility.Enums.AggregationEnum.All,
'',
',',
)
sol.Close() There are a couple other ways to pull data out of the file, those all seem to work both through the wrapper and with snippets similar to the above. While it seems like there is some change being introduced between Given that other methods seem to work, and that the error seems to be isolated to code that I wrote, I am comfortable shelving this and taking a little more time to review things on my side. |
I'll close this one for now, as there is nothing "actionable" from our side. I would suggest that you open a bug report on the vendor's Github and just reference me in it. Since their API is apparently .NET Core nowadays, they could really profit from having this work. |
Environment
Details
I am importing the DLL's for PLEXOS, a power system application compiled with .NET, to perform analysis on the simulation outputs, and I have built a wrapper around the .NET methods (see here for examples from the developers) to streamline the interaction. My use case is to use the API to extract data from a PLEXOS Solution File (a .zip with a bunch of binary files).
I've been trying to keep up with pythonnet updates and spend some time earlier in the year using alpha-2 which I was able to get working with minor updates. While I typically try to avoid alphas the latest PLEXOS versions are being compiled with .NET 6 and I wasn't having luck with
2.5.2
; however, for compatibility they have also been providing the DLLs compiled with .NET 4.8 which is what I'm using here. (NOTE: I have since figured out that we're running into pythonnet/clr-loader#20 with the .NET 6 DLLs).I've had a few spare cycles this week so I've been making updates to different tools including the wrapper mentioned above. One of these changes is updating from a2 to rc4, with the goal of bumping to the release when it is available. Unfortunately, I am running into some issues when trying to call the .NET methods and have been able to isolate that the code works with a2 and does not work with rc4.
With rc4 I am getting the following error:
I suspect the issue is with the enumerations. However, I know data of the right types is being passed to the function since if I change any of the input arguments (e.g.
SimulationPhaseId
as a string) I will get aTypeError
and a message that "No method matches given argument."Looking for some direction on what to debug next and appreciate any insights!
The text was updated successfully, but these errors were encountered: