xx.accessor shadow compile report error "Could not load file or assembly" after upgrading from vs08 to vs2010
-
jeudi 3 mai 2012 08:34
The error is
Could not load file or assembly 'XXX, Version=12.3.13110.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified
I tried to remove the unit test project and create a new unit test by "Create Unit Test", but the error wasn't fixed. Did anyone meet it before? thanks very much
Ody
- Déplacé lucy-liu vendredi 4 mai 2012 05:10 it is a unit test issue (From:MSBuild)
Toutes les réponses
-
vendredi 4 mai 2012 05:09
Hi Odysseus,
This is a unit test issue, I will move it to Visual Studio Unit Testing forum for a better support.
Thank you for your understanding!
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
-
vendredi 4 mai 2012 07:50Modérateur
Hi Ody,
Thank you for posting in the MSDN forum.
Abhishek provided some information which could generate this issue.
- Firstly, private accessor is no longer supported and could be causing the issue.
- Is the assembly a 64 bit assembly by chance? Since VS is 32 bit, it cannot load pure 64 bit assembly
- The C# project might not have been built and referenced correctly.
References:
Unit Tests - Unable to run - "Could not find file or assembly…
VS2010 C# unit tests compile, but don't load in test list editor on 64 bit machine running in 64 bit process. Hope it could help.
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
-
vendredi 4 mai 2012 08:17
It think it should be caused by the second. XXX refer to a x64 c++.net project.
You mentioned private accessor is no longer supported, I am wondering if there is the replacement way to test private method. Thanks
Ody
- Modifié Odysseus Yang vendredi 4 mai 2012 08:34
-
vendredi 4 mai 2012 09:34Modérateur
Hi Ody,
Glad to receive your reply.
You mentioned private accessor is no longer supported, I am wondering if there is the replacement way to test private method.
I think I didn’t describe it clearly. Sorry about it. Actually the VS2010 support the private accessor. But it has been removed in VS 2011 beta here. I mean that maybe the accessor is impacted, or it doesn’t work, and then it will impact the unit tests.
Have a nice weekend,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
-
vendredi 4 mai 2012 10:14Ok, I didn't install VS2011. So seems the problem is the source project has reference to x64 assembly, Is there workaround solution?
Ody
-
vendredi 4 mai 2012 14:28
Hi,
VS 2010 (including SP1) doesn't support testing on x64 test assembly. Test assembly should be AnyCPU.
Thanks.
-
samedi 5 mai 2012 03:14
Dhruv
I assume your test assembly means unit test assembly, it is AnyCPU, it is testing a managed assembly which refers to a x64 c++.net assembly that caused the issue according to Jack Zhai's reply. Do you have any idea to resolve it?
Ody
-
lundi 7 mai 2012 04:31Modérateur
Hi Dhruv’s
Thank you for your friendly assistance.
Hi Ody,
Since I couldn’t repro your project, so I’m not very sure which reason generated this issue in your APP.
But as far as I know, if your application is 32 bit only, they cannot load the 64 bit assembly (unless it is compiled as AnyCPU) and consequently, you cannot run your unit tests.
Two blogs about the related issue:
Visual Studio Team Test Load Agent Goes 64 Bit!
Working around the AnyCPU Limitation with Visual Studio Unit Tests
If still not help, you could share us a sample, we try to check it.
Sincerely,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
-
lundi 7 mai 2012 06:22
Guys
Thanks very much for your help. I found the the issue is caused by .net framework confliction by chance. One utility project is using 3.0, and the test target project reference to utility is using 4.0, after I upgrade utility to 4.0. The error disappeared. I don't know the root cause, I will try more and let you know if I find the root cause.
And I summarized the confusions and clarified them as below
- Firstly, private accessor is no longer supported and could be causing the issue.
It is not true in VS2010. It may become true in VS2011. - Is the assembly a 64 bit assembly by chance? Since VS is 32 bit, it cannot load pure 64 bit assembly
I am not sure what pure 64 bit assembly means, but what I saw is unit test can load 64 bit assembly - VS 2010 (including SP1) doesn't support testing on x64 test assembly
It is not true in VS2010, Test Settings allow to choose run test in 32 bit or 64 bit process
Ody
- Proposé comme réponse Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator mardi 8 mai 2012 02:01
- Marqué comme réponse Odysseus Yang mardi 8 mai 2012 02:03
- Firstly, private accessor is no longer supported and could be causing the issue.
-
mardi 8 mai 2012 07:45
The root cause has been located. The System.ServiceModel.Channels.Binding is different in 3.0 and 4.0. A abstract class in utility project (using 3.0) has a property ChannelBinding to return Binding, and its' child class in JobProcessor project (using 4.0) implement the property. When shadow target checks reference, it reports the error, Method 'get_ChannelBinding' in type 'JobProcessor.CfsCallerProxy' from assembly 'JobProcessor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. Because Binding in 3.0 and 4.0 are different, so they are treated as different classes by private accessor. It is a bug of private accessor, but consider it would be deprecated in 2011, I think no one will fix it. Below is windbg steps for your reference.
0:020> !soe -create System.Reflection.ReflectionTypeLoadException
Breakpoint set
0:020> g
(2310.9e8): C++ EH exception - code e06d7363 (first chance)
(2310.9e8): C++ EH exception - code e06d7363 (first chance)
(2310.9e8): C++ EH exception - code e06d7363 (first chance)
(2310.9e8): C++ EH exception - code e06d7363 (first chance)
(2310.9e8): C++ EH exception - code e06d7363 (first chance)
(2310.9e8): C++ EH exception - code e06d7363 (first chance)
(2310.9e8): CLR exception - code e0434352 (first chance)
'System.Reflection.ReflectionTypeLoadException hit'
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=0034c270 ebx=00000005 ecx=00000005 edx=00000000 esi=0034c31c edi=00453328
eip=75ebb9bc esp=0034c270 ebp=0034c2c0 iopl=0 nv up ei pl nz ac po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000212
KERNELBASE!RaiseException+0x58:
75ebb9bc c9 leave
0:000> !threads
ThreadCount: 23
UnstartedThread: 0
BackgroundThread: 18
PendingThread: 0
DeadThread: 5
Hosted Runtime: yes
PreEmptive GC Alloc Lock
ID OSID ThreadOBJ State GC Context Domain Count APT Exception
0 1 9e8 00453328 4220 Enabled 0ede4750:0ede5178 08ebdf68 0 STA System.Reflection.ReflectionTypeLoadException (0ede45d4)
6 2 33f8 02e556c0 b220 Enabled 0ecdf130:0ece10e8 0044cf30 0 MTA (Finalizer)
7 3 36e8 02e5af20 1220 Enabled 00000000:00000000 0044cf30 0 Ukn
10 4 274c 08eef2d8 7220 Enabled 00000000:00000000 0044cf30 0 STA
21 d 35a0 0cc65d98 200b220 Enabled 00000000:00000000 0044cf30 0 MTA
22 e 2e68 0cc66568 200b220 Enabled 00000000:00000000 0044cf30 0 MTA
23 f 2960 0cc66d38 200b220 Enabled 00000000:00000000 0044cf30 0 MTA
24 10 664 0ccbcf50 200b220 Enabled 00000000:00000000 0044cf30 0 MTA
25 11 28e0 0cccc318 200b220 Enabled 00000000:00000000 0044cf30 0 MTA
26 12 2d6c 0ccf3790 100a220 Enabled 00000000:00000000 0044cf30 0 MTA (Threadpool Worker)
14 14 298c 0ccf41a0 220 Enabled 00000000:00000000 0044cf30 0 MTA
XXXX 9 0ccf73f0 1019820 Enabled 00000000:00000000 0044cf30 0 MTA (Threadpool Worker)
XXXX 15 0ccf4bb0 1019820 Enabled 00000000:00000000 0044cf30 0 MTA (Threadpool Worker)
XXXX 6 0ccf7e00 1019820 Enabled 00000000:00000000 0044cf30 0 MTA (Threadpool Worker)
XXXX 5 0ccf8308 1019820 Enabled 00000000:00000000 0044cf30 0 MTA (Threadpool Worker)
XXXX 1d 0ccf9220 1019820 Enabled 00000000:00000000 0044cf30 0 Ukn (Threadpool Worker)
18 16 16c0 0ccf50b8 3009220 Enabled 0ed461d4:0ed470e8 0044cf30 0 MTA (Threadpool Worker)
2 1c a40 0ccf8d18 1009220 Enabled 0ece5154:0ece70e8 0044cf30 0 MTA (Threadpool Worker)
12 1b 1514 0ccf8810 1009220 Enabled 0ece1124:0ece30e8 0044cf30 0 MTA (Threadpool Worker)
17 13 25b4 0ccf3c98 1009220 Enabled 0eda3138:0eda50e8 0044cf30 0 MTA (Threadpool Worker)
13 b 3030 0ccf6ee8 1009220 Enabled 00000000:00000000 0044cf30 0 MTA (Threadpool Worker)
16 7 240c 0ccf69e0 1009220 Enabled 00000000:00000000 0044cf30 0 MTA (Threadpool Worker)
19 a 287c 0ccf9728 1009220 Enabled 00000000:00000000 0044cf30 0 MTA (Threadpool Worker)
0:000> !DumpObj /d 0ede45d4
Name: System.Reflection.ReflectionTypeLoadException
MethodTable: 6dea8064
EEClass: 6dbeaa08
Size: 92(0x5c) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
MT Field Offset Type VT Attr Value Name
6debf92c 400004b 4 System.String 0 instance 00000000 _className
6dec0174 400004c 8 ...ection.MethodBase 0 instance 00000000 _exceptionMethod
6debf92c 400004d c System.String 0 instance 00000000 _exceptionMethodString
6debf92c 400004e 10 System.String 0 instance 03d35950 _message
6deb3f84 400004f 14 ...tions.IDictionary 0 instance 00000000 _data
6debfb8c 4000050 18 System.Exception 0 instance 00000000 _innerException
6debf92c 4000051 1c System.String 0 instance 00000000 _helpURL
6debf568 4000052 20 System.Object 0 instance 00000000 _stackTrace
6debf568 4000053 24 System.Object 0 instance 00000000 _watsonBuckets
6debf92c 4000054 28 System.String 0 instance 00000000 _stackTraceString
6debf92c 4000055 2c System.String 0 instance 00000000 _remoteStackTraceString
6dec28f8 4000056 3c System.Int32 1 instance 0 _remoteStackIndex
6debf568 4000057 30 System.Object 0 instance 00000000 _dynamicMethods
6dec28f8 4000058 40 System.Int32 1 instance -2146232830 _HResult
6debf92c 4000059 34 System.String 0 instance 00000000 _source
6deba9ac 400005a 44 System.IntPtr 1 instance 0 _xptrs
6dec28f8 400005b 48 System.Int32 1 instance -532462766 _xcode
6de7a21c 400005c 4c System.UIntPtr 1 instance 0 _ipForWatsonBuckets
6de79808 400005d 38 ...ializationManager 0 instance 0ede4734 _safeSerializationManager
6de76ba8 40010eb 50 System.Object[] 0 instance 0ede3898 _classes
6de76ba8 40010ec 54 System.Object[] 0 instance 0ede45c0 _exceptions
0:000> !DumpObj /d 0ede45c0
Name: System.Object[]
MethodTable: 6de76ba8
EEClass: 6dbf9688
Size: 20(0x14) bytes
Array: Rank 1, Number of elements 1, Type CLASS (Print Array)
Element Type:System.Exception
Fields:
None
0:000> !da 0ede45c0
Name: System.Exception[]
MethodTable: 6de76ba8
EEClass: 6dbf9688
Size: 20(0x14) bytes
Array: Rank 1, Number of elements 1, Type CLASS
Element Methodtable: 6debfb8c
[0] 0ede40f4
0:000> !DumpObj /d 0ede40f4
Name: System.TypeLoadException
MethodTable: 6deb4900
EEClass: 6dba2f78
Size: 100(0x64) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
MT Field Offset Type VT Attr Value Name
6debf92c 400004b 4 System.String 0 instance 00000000 _className
6dec0174 400004c 8 ...ection.MethodBase 0 instance 00000000 _exceptionMethod
6debf92c 400004d c System.String 0 instance 00000000 _exceptionMethodString
6debf92c 400004e 10 System.String 0 instance 0ede442c _message
6deb3f84 400004f 14 ...tions.IDictionary 0 instance 00000000 _data
6debfb8c 4000050 18 System.Exception 0 instance 00000000 _innerException
6debf92c 4000051 1c System.String 0 instance 00000000 _helpURL
6debf568 4000052 20 System.Object 0 instance 00000000 _stackTrace
6debf568 4000053 24 System.Object 0 instance 00000000 _watsonBuckets
6debf92c 4000054 28 System.String 0 instance 00000000 _stackTraceString
6debf92c 4000055 2c System.String 0 instance 00000000 _remoteStackTraceString
6dec28f8 4000056 3c System.Int32 1 instance 0 _remoteStackIndex
6debf568 4000057 30 System.Object 0 instance 00000000 _dynamicMethods
6dec28f8 4000058 40 System.Int32 1 instance -2146233054 _HResult
6debf92c 4000059 34 System.String 0 instance 00000000 _source
6deba9ac 400005a 44 System.IntPtr 1 instance 0 _xptrs
6dec28f8 400005b 48 System.Int32 1 instance -532462766 _xcode
6de7a21c 400005c 4c System.UIntPtr 1 instance 0 _ipForWatsonBuckets
6de79808 400005d 38 ...ializationManager 0 instance 0ede4158 _safeSerializationManager
6debf92c 4000401 50 System.String 0 instance 0ede3fe8 ClassName
6debf92c 4000402 54 System.String 0 instance 0ede4060 AssemblyName
6debf92c 4000403 58 System.String 0 instance 0ede402c MessageArg
6dec28f8 4000404 5c System.Int32 1 instance 6012 ResourceId
0:000> !DumpObj /d 0ede442c
Name: System.String
MethodTable: 6debf92c
EEClass: 6dbf8ba0
Size: 378(0x17a) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
String: Method 'get_ChannelBinding' in type 'JobProcessor.CfsCallerProxy' from assembly 'JobProcessor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Fields:
MT Field Offset Type VT Attr Value Name
6dec28f8 4000103 4 System.Int32 1 instance 182 m_stringLength
6dec1d48 4000104 8 System.Char 1 instance 4d m_firstChar
6debf92c 4000105 8 System.String 0 shared static Empty
Ody

