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

replace GetExecutingAssembly with more proper assembly #183

Open
SelvinPL opened this issue Apr 26, 2024 · 2 comments
Open

replace GetExecutingAssembly with more proper assembly #183

SelvinPL opened this issue Apr 26, 2024 · 2 comments

Comments

@SelvinPL
Copy link

SelvinPL commented Apr 26, 2024

Can we replace code like:

Assembly executingAssembly = Assembly.GetExecutingAssembly();
string str = typeof(RVSplitContainer).Namespace + ".Resources.";
m_bitmaps[4] = new Bitmap(executingAssembly.GetManifestResourceStream(str + "SplitterHorizExpand.png"));

from here (and in similar places)

with more context aware code, like:

Assembly executingAssembly = typeof(RVSplitContainer).Assembly;
string str = typeof(RVSplitContainer).Namespace + ".Resources.";
m_bitmaps[4] = new Bitmap(executingAssembly.GetManifestResourceStream(str + "SplitterHorizExpand.png"));

why?

Because in other case it is not working with single code publish.
image

it is working fine without publishing as single file but this nasty single file assembly connnot be referenced

@lkosson
Copy link
Owner

lkosson commented Apr 26, 2024

Both Assembly.GetExecutingAssembly() and typeof(RVSplitContainer).Assembly should return same value, for both normal and single-file deployment (and both would fail if used with Native AoT).

Unfortunately this package won't work with single file deployment, because it uses Roslyn VB compiler to compile RDLC formulas and scripts. To do so, Roslyn needs to reference and load assemblies for both .NET, Report Viewer and (if used) your project. When you publish to a single file, Roslyn gets confused and throws an exception as in your screenshot. I haven't checked if anything changed since .NET 6, though.

(duplicate: #49)

@frankashley
Copy link

I tried to do single file publish and ended up here. WinForms .NET 8 seems to work if you use the IncludeAllContentForSelfExtract flag and change the two uses of Environment.CurrentDirectory with Directory.GetParent(Assembly.GetExecutingAssembly().Location)!.FullName. I am using ReportPath, not embedded resource. Maybe not the best but I was getting slowed down with clickonce selfcontained and having each file scanned or something slow, both in publish and in install. This ended up better, but still feels lame. Maybe it would be cool to figure out what Rosylyn needs and then exclude them from the single file if it wasn't a huge list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants