✅ Can't get `InternalsVisibleTo` to work
From assembly (project)
A.B
I added the following in a file
But the assembly A.B.Test
can't see MyClass
.
Is there something extra that I should do?46 Replies
Nope, that should do it
So what you recommend at this point is for me to make extra sure that the names of the assemblies are correct, or what?
i recommend sharing the error
I just disassembled
A.B
and I can see class Myclass
in it
but should I also see that instruction for the CompilerService
?
The error is quite simple:
incompatible frameworks i guess?
you could be onto something
A.B.Tests is a
netstandard2.0
proj. Shouldn't that be the most compatible of them all, though?i don't know. why is it that version?
forced to by your company?
yes, correct
it has to be portable and part of a lib and bla bla bla
so I don't have a say on
netstandard2.0
or nothm, cringe
net core is the most portable
i mean, the entire point of it is to be cross platform
let me rephrase: I don't know why but it's set
netstandard2.0
so forget what I said
I don't recall the exact reasoni can't test that setup because i'm on linux
how sure are you that's the framework compatibility an issue here?
like 10%?
i don't know much about it
can't linux target netstandard?
ask in #roslyn
but not framework
and you included
A.B.Tests (net472)
this soI can temporarily remove framework
but you can see that the issue is also for core
i actually can't see that, no
A.B.Tests (net472), A.B.Tests (netcoreapp3.1)
in fact i showed that the issue does not exist
the error I posted
this
oh, i mustve gotten confused
np
yeah then i'm definitely more sure that it's the target frameworks
I see
make sure to ask in the roslyn channel, they're sure to know more
thank you
It's the most compatible library type. Your tests can't be that though
My tests are infact net472 and netcoreapp3.1
netstandar2.0 is the assembly where the internal class is defined. And I need access to it from the tests
Can you post a repro?
🙂
Why the smiley?
I'll try a repro proj tomorrow morning (CET)
that'll likely work
Well, the other things to check: make sure the assembly name is correct
and I'll be back at "it's just somethign else in my proj"
that's why the smiley
Build the test project, and verify that the dll has the assembly name you expect
I checked the names 4 times
Not file name
Assembly name
I looked inside the dll and verified that all is where I expect it to be and properly named
The other thing to check is whether strongnaming is involved
If a.b is strongnamed, a.b.test must also be strongnamed
Not file name Assembly nameI'll check exactly the diff here once the dll is loaded in a disassembler (if this is the name), I assume that the name shown there is the name of the assembly am I wrong in assuming this? I'll look into the lib being strong-named
Look at the assembly info section of your disassembler
the name looks correct
Then a.b is likely being strongnamed
I understand. Thank you for following up. I'll keep investigating
this was not a repro project. I was just meant to give an idea of what I was doing.
but I'll check naming again
my issue was a funny one not really related to this working or not
I had the same namespace (by name) in both assembly and so
MyClass
was not found in MyNamespace
because MyNamespace
was not the one from the external assembly, but it was fetch from the same assembly.
An extern alias fixed my issues.
Thank you all for the support.Closed!