# Strange assembly path resolution

**URL:** https://talk.remobjects.com/t/strange-assembly-path-resolution/28800
**Category:** Oxygene
**Tags:** visual-studio
**Created:** [August 31, 2023, 11:53am UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800 "2023-08-31T11:53:38Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [August 31, 2023, 11:53am UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/1 "2023-08-31T11:53:38Z")

</div>

Hi,  
we have been investigating an issue, where an invalid assembly version appeared in build output and discovered this:

If .elements project contains a reference like this one:  
`<Reference Include="System.Composition.AttributedModel"/>`  
Then in our case: elements resolves path

` C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\devportal\59a59d0c\3d0eb4c1\assembly\dl3\e8fdde2b\8775c8da_663ad901\System.Composition.AttributedModel.dll`

to a “Temporary [ASP.NET](http://ASP.NET) Files” folder, which is absolutely offtopic and contains many assemblies but unrelated with the current build task. Of course the reference itself is invalid. Its not a (.netframework) system assembly and should not be resolved, its a .net 7 assembly or an assembly in a Nuget package. This is a simple simulation case, here happened a total mess in anther dependent project.

After all, ive experimented and tried to force the path via HintPath,

```auto
<Reference Include="System.Composition.AttributedModel">
  <HintPath>"C:\Users\tumal\.nuget\packages\system.composition.attributedmodel\1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll"</HintPath>
</Reference>

```

but result is the same. Resolved path is still Temporary [ASP.NET](http://ASP.NET) files.

My questions are:  
Why elements resolves assemblies from Temporary [ASP.NET](http://ASP.NET) files ?  
Why elements doesnt bother with the hintpath with higher priorty then temp ?  
Can i turn it off ?

Thanks.

---

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [August 31, 2023, 11:55am UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/2 "2023-08-31T11:55:51Z")

</div>

Sending:  
Demo: [ClassLibrary5.zip](https://talk.remobjects.com/uploads/short-url/pRbgVHWo8CKkmdKLYj2tlhzoNQu.zip) (1.2 KB)  
[build.log.txt](https://talk.remobjects.com/uploads/short-url/lMlprqClPLaWsuRsKVZ2hneNuXv.txt) (31.9 KB)

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [August 31, 2023, 12:45pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/3 "2023-08-31T12:45:59Z")

</div>

Try building from command line with EBuild and the `--debug-reference-resolving` switch, which should emit a lot ore details of ALL the places where it looks for dlls, and in which order.

---

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [September 4, 2023, 11:22am UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/4 "2023-09-04T11:22:36Z")

</div>

OK, there is a log [ebuild.txt](https://talk.remobjects.com/uploads/short-url/aAmOxyToX98QOOEUJryxx8XALGX.txt) (270.3 KB), but i cant see anything what caused 800 attempts to find an assembly in Temporary ASP .NET files, looks like by design. I guess this only makes the resolution slow..

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 4, 2023, 12:43pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/5 "2023-09-04T12:43:42Z")

</div>

> [@tescosw](#):
>
> OK, there is a log [ebuild.txt](https://talk.remobjects.com/uploads/short-url/aAmOxyToX98QOOEUJryxx8XALGX.txt) (270.3 KB), but i cant see anything what caused 800 attempts to find an assembly in Temporary ASP .NET files, looks like by design. I guess this only makes the resolution slow…

It looks like you have that path set somewhere in one of the AssembnlyFolder(Ex) registry keys. Can you do a fill registry search for “Temporary [ASP.NET](http://ASP.NET) Files” and see if it pops up in any of those?

Also, where would you _expect_ `System.Composition.AttributedModel` to be found? it seems it only goes off into the bushes to look for it after it does _not_ find it in the regular places. e.g. compare to how other files ar fine where expected

```auto
Checking C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Core.dll, YEP

```

vs

```auto
Checking C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Composition.AttributedModel.dll, NOPE

```

---

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [September 5, 2023, 10:05am UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/6 "2023-09-05T10:05:58Z")

</div>

> [@mh](#):
>
> It looks like you have that path set somewhere in one of the AssembnlyFolder(Ex) registry keys. Can you do a fill registry search for “Temporary [ASP.NET](http://ASP.NET) Files” and see if it pops up in any of those?

It does not.

> [@mh](#):
>
> Also, where would you _expect_ `System.Composition.AttributedModel` to be found?

I expect the compiler will throw Unknown Type (System.Composition.Export) error beaces this reference should not be resolved. It has to be a nuget reference.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 5, 2023, 12:00pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/7 "2023-09-05T12:00:48Z")

</div>

> [@tescosw](#):
>
> I expect the compiler will throw Unknown Type (System.Composition.Export) error beaces this reference should not be resolved.

Well, it could be resolved 😉

> [@tescosw](#):
>
> It has to be a nuget reference.

So really, were; chasing a bug that’s a test case error, then? If you change it to am proper NuGet reference, is all ok?

---

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [September 5, 2023, 12:51pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/8 "2023-09-05T12:51:56Z")

</div>

Sorry, i cant send you the original reproduce with more than 300 dlls in the hell.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 5, 2023, 1:25pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/9 "2023-09-05T13:25:28Z")

</div>

> [@tescosw](#):
>
> Sorry, i cant send you the original reproduce with more than 300 dlls in the hell.

Okay, bit how did it get there, if these were never valid .dlls that would remove without NuGet?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 5, 2023, 1:32pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/10 "2023-09-05T13:32:57Z")

</div>

I’m adding more logging to a new build, to see _why_/where it goes down into `Temporary ASP.NET Files\devportal\59a59d0c\3d0eb4c1\assembly\dl3\e8fdde2b\8775c8da_663ad901`.

**Update** actually, no need to. I know specifically why. the code that changes `.NETFramework\v<version>` is explicitly told to recurse all subfolders. Now, do I know specifically _why_? no, because this was written 10-15 years ago. But I’m pretty sure if I drop this, it will fail for others.

---

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [September 6, 2023, 7:03am UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/11 "2023-09-06T07:03:12Z")

</div>

> [@mh](#):
>
> Temporary [ASP.NET](http://ASP.NET)

Im pretty sure that searching in Temporary [ASP.NET](http://ASP.NET) Files is not usefull. Framework assemblies in this tree are not for referencing. I was askin, because i was not sure if it is designed or happens due to some of our specifics. I believe this is just a time burner.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 6, 2023, 11:32am UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/12 "2023-09-06T11:32:43Z")

</div>

> [@tescosw](#):
>
> Im pretty sure that searching in Temporary [ASP.NET](http://ASP.NET) Files is not usefull

Indeed, bit its searching “C:\Windows\Microsoft.NET\Framework64\v4.0.30319” recursively (that part is necessary), and there’s nothing special about “Temporary [ASP.NET](http://ASP.NET) Files” vs other sub-folders, so it gets searched like all others.

Also since the whole issue only arises because you have bad references _to begin with_, I fail to see how this is this bad an issue. If I “fixed” this, all these 300+ references you mention would fail anyways, and you’d have to adjust them to correctly be NuGet references…

---

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [September 6, 2023, 12:07pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/13 "2023-09-06T12:07:04Z")

</div>

Yes, but assembly resolution must by precisely done, versions/builds are important. In our case, there is no 300 hundred wrong references. There is 300 netframework / netstandard /net assemblies which refer other specific version on `System.Composition.AttributedModel` and others. Presence of one elements projects, with wrong reference in dependency chain affects the whole process.

It it will not use Temp:

1. it will tell the developer that he did it wrong immediately.
2. It might be a reason why resolving references is sometimes super slow and sometimes OK which we also observe but its hard to reporduce.

On top of that. I think thath the directory tree "C:\Windows\Microsoft.NET" is not good for assembly reference resolution at all. There are runtime assemblies. The right folder should be: _%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework.NETFramework_ only.  
But im not expert here.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 6, 2023, 12:14pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/14 "2023-09-06T12:14:23Z")

</div>

> [@tescosw](#):
>
> On top of that. I think thath the directory tree “C:\Windows\Microsoft.NET” is not good for assembly reference resolution at all. There are runtime assemblies. The right folder should be: _%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework.NETFramework_ only.

It checks in both.

> [@tescosw](#):
>
> But im not expert here.

And there’s a reason it does check in both / falls back to `C:\Windows\Microsoft.NET`, if the other doesn’t work. I didn’t just pull EBuild assembly resolution out of my nose one night after having too much to drink 😉. This is fine-tuned over years based on many different scenarios, and doesn’t do anything “just for fun” that wasn’t added because it was needed for a certain scenario.

Assembly Resolution (for .NET) is a mess, yes. Mostly because, well, when has Microsoft ever designed something that’s not. But it’s a necessary mess.

But believe me, it’s cleaner in EBuild than it is in MSBuild (which, for just one example, will just completely not tell if you if it can’t find an assembly _at all_, and then let you wonder why you get “unknown identifiers” all offer the place, for stuff that you’re sure you’ve referenced).

---

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [September 6, 2023, 1:31pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/15 "2023-09-06T13:31:16Z")

</div>

Please, you take it too much personal i think. Ive started this as a question, i dont need you to change a think. It is as it is wit all pros and cons and it cant be turned off. We can live with that, even if i dont agree with you.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 6, 2023, 1:36pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/16 "2023-09-06T13:36:54Z")

</div>

> [@tescosw](#):
>
> Please, you take it too much personal i think.

No worries. My apologies if it came across as such, that was not my intention.

I’m merely trying to explain that its complex, and a bit of a house of cards (build on sand that we don’t move ourselves ;).

What I can try to do for you is _specifically_ exclude “Temporary [ASP.NET](http://ASP.NET) Files” as a hardcoded name from the “check all sub-folders” recursion code… and wait and see if that breaks things for anyone else.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 6, 2023, 2:34pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/17 "2023-09-06T14:34:05Z")

</div>

> [@mh](#):
>
> What I can try to do for you is _specifically_ exclude “Temporary [ASP.NET](http://ASP.NET) Files” as a hardcoded name from the “check all sub-folders” recursion code… and wait and see if that breaks things for anyone else.

Up in Personal Downloads; pls let me know if this helps.

---

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [September 11, 2023, 1:35pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/18 "2023-09-11T13:35:10Z")

</div>

Thanks for the effort, the resference resolution looks better. There is a 800 less file existence checks at the result is `E: Reference 'System.Composition.AttributedModel' could not be resolved for target 'Echoes' (Echoes .NET anycpu).` Which is proper result. No other problems appeared during the resolution here, but we could not complete testing becase of compilation errors in almost every project. Looks like another unrelated bug ?

```auto
Error (E0) Internal error: System.NullReferenceException: Object reference not set to an instance of an object.
   at RemObjects.Elements.Code.Compiler.Compiler.get_DefaultUsesPrefixes()
   at RemObjects.Elements.Code.Compiler.Compiler.a(IHolderOfUses a, MyImmutableDictionary`2& b, Int32& c, String d, IPosition e, Boolean f)
   at RemObjects.Elements.Code.Compiler.Compiler.a(IHolderOfUses a, MyImmutableDictionary`2& b, Int32& c, Uses d, MyImmutableDictionary`2 e)
   at RemObjects.Elements.Code.Compiler.Compiler.ResolveUsesFor(Boolean aEverything)
   at RemObjects.Elements.Code.Compiler.Compiler.ResolveUsesFor(CodeFile aCodeFile, Boolean aEverything)
   at RemObjects.Elements.Code.Compiler.Compiler.ResolveUsesFor(CSharpNamespace aCodeFile, Boolean aEverything)
   at RemObjects.Elements.Code.Compiler.Compiler.GetNamespaceInfo(IHolderOfUses aUses, Boolean aEverything)
   at RemObjects.Elements.Code.Compiler.ResolveTypesCompiler.a(Compiler a, ITypeResolutionScope b, ResolveNamedFlags c, Int32 d, Identifier e, Identifier f, String g, BaseType h, Action`2 i, TypeReference j)
   at RemObjects.Elements.Code.Compiler.ResolveTypeVisitorCompiler.IntResolve __$mapped______ (Compiler self, ITypeResolutionScope aScope, NamedTypeReference aType, ResolveNamedFlags aFlags)
   at RemObjects.Elements.Code.Compiler.ResolveTypesCompiler.ResolveType __$mapped______ (Compiler self, ITypeResolutionScope aScope, TypeReference aTR, ResolveNamedFlags aFlags)
   at RemObjects.Elements.Code.AttributeImplementation.get_AttributeType()
   at RemObjects.Elements.Code.Compiler.Compiler.CheckAttributes(ITypeResolutionScope aScope, AttributeTargets at, MyImmutableArray`1 aAtt, Action`1 aRemove, MyImmutableArray`1 aXML, IBaseInfo aTarget, Boolean aSkipXML)
   at RemObjects.Elements.Code.Compiler.ResolveMembersCompiler.ResolveMembers__$mapped(Compiler self)
   at RemObjects.Elements.Code.Compiler.Compiler.Compile()	Sys_jadro.SQL 0

```

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 11, 2023, 1:41pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/19 "2023-09-11T13:41:17Z")

</div>

> [@tescosw](#):
>
> Looks like another unrelated bug ?

It does, yeah, although not one I see here (but changes were made to DefaultUsesPrefixes before and, i believe, after 2869 built, so maybe that’s already fixed… Does this happen in any project, or only a specific one?

> [@tescosw](#):
>
> There is a 800 less file existence checks at the result is `E: Reference 'System.Composition.AttributedModel' could not be resolved for target 'Echoes' (Echoes .NET anycpu).` Which is proper result.

Cool.

---

<div class="post-metadata">

### Author: ![tescosw](https://talk.remobjects.com/user_avatar/talk.remobjects.com/tescosw/32/20488_2.png) [@tescosw](https://talk.remobjects.com/u/tescosw)
#### Post date: [September 11, 2023, 1:50pm UTC](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800/20 "2023-09-11T13:50:54Z")

</div>

> [@mh](#):
>
> It does, yeah, although not one I see here (but changes were made to DefaultUsesPrefixes before and, i believe, after 2869 built, so maybe that’s already fixed… Does this happen in any project, or only a specific one?

In 2 of 6 ive tested. Both are C#/Oxygene mixed. Others are pure oxygene.

[Next page](https://talk.remobjects.com/t/strange-assembly-path-resolution/28800.md?page=2)
