I have the follow lines:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
private global::AjaxControlToolkit.ToolkitScriptManager #__BuildControlToolkitScriptManager1() {
global::AjaxControlToolkit.ToolkitScriptManager #__ctrl;
and I got this error:
The type 'System.Web.UI.ScriptManager' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I choose Add Reference>.Net>system.web.extension version 4.0 in visual web developer and still get same error .
What can I do?
Related
I am working on an old WebForms project.
Occasionally it won't build
The type 'HttpRequestMessage' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
The exception above is thrown on Request on this line
public class MyController : ApiController
{
[System.Web.Http.HttpPost]
public string Test()
{
string data = Request.Content.ReadAsStringAsync().Result;
}
}
To be able to run the website, I simply have to Rebuild Solution (without changing anything at all).
Any idea what may be causing it?
Add below code in you web.config
<configuration>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
</system.web>
</configuration>
I've created a very basic Logging block and Exception Handling block. In my code, I went to go test the Exception Handling (I know the Logging block works) with the following:
public void RunScriptClean()
{
try
{
throw new FileNotFoundException();
}
catch (FileNotFoundException ex)
{
var b = ExceptionPolicy.HandleException(ex, "Logging Policy");
if (b)
throw;
}
}
However, on the very first line of the catch block, I get this long winded exception and my application crashes:
Exception occured: The current build operating (build key Build Key [Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, Logging Policy]) failed: The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided. (Strategy type ConfiguredObjectStrategy, index 2).
I have absolutely no idea what it's referring to when it says the type cannot be resolved. I've added references to Microsoft.Practices.EnterpriseLibrary.Common/ExceptionHandling/Logging and Ms.Practices.ObjectBuilder2. This one class has using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling included at the top.
Added a screenshot of the configuration tool looking at my AppConfig file:
I'm sure I'm missing something basic, but it's tough to find a tutorial for EAB 4.1-- CodeProject has a lot for the original versions but I couldn't make much of them...
Edit I tried creating a new Formatter and naming it TextExceptionFormatter but that didn't change anything. Wasn't sure if maybe some how the FormatterType property on my Logging Handler was tied to that node.
And the actual block of XML from App.config:
<exceptionHandling>
<exceptionPolicies>
<add name="Logging Policy">
<exceptionTypes>
<add type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="NotifyRethrow" name="Exception">
<exceptionHandlers>
<add logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
priority="0" useDefaultLogger="false" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Logging Handler" />
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>
</exceptionHandling>
I found this SO question: Cannot resolve type runtime error after registering the Enterprise Library into the GAC but even after changing the Version segment of the fullName attribute my app still behaves the same.
Alright, I was able to find a sample application that used the Logging handlers. Turns out I needed a reference to ExceptionHandling.Logging:
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging ****
Microsoft.Practices.EnterpriseLibrary.Logging
Microsoft.Practices.ObjectBuilder2
Where as I only had a references to:
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Microsoft.Practices.EnterpriseLibrary.Logging
Microsoft.Practices.ObjectBuilder2
I want to use EnterpriseLibrary 5.0 dlls for logging in my project.
For this I have added these dll to my references:
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.Data
Microsoft.Practices.EnterpriseLibrary.Logging
Microsoft.Practices.EnterpriseLibrary.Logging.Database
And then I write this:
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;
And then I wrote:
LogEntry logEntry = new LogEntry();
logEntry.Message = "Message";
Logger.Write(logEntry);
But when my code executed, I get this exception at the last line:
Activation error occured while trying to get instance of type
LogWriter, key ""
that has this InnerException:
Resolution of the dependency failed, type =
\"Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter\", name =
\"(none)\".\r\nException occurred while: Calling constructor
Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener(System.String
fileName, System.String header, System.String footer,
Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter
formatter).\r\nException is: IOException - The device is not
ready.\r\n\r\n-----------------------------------------------\r\nAt
the time of the exception, the container was:\r\n\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl,LogWriter.default
(mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter,
(none))\r\n Resolving parameter \"structureHolder\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder
structureHolder,
Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider
instrumentationProvider,
Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator
updateCoordinator)\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,LogWriterStructureHolder.default
(mapped from
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,
(none))\r\n Resolving parameter \"traceSources\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(System.Collections.Generic.IEnumerable1[[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35]] filters,
System.Collections.Generic.IEnumerable1[[System.String, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
traceSourceNames,
System.Collections.Generic.IEnumerable1[[Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35]] traceSources,
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
allEventsTraceSource,
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
notProcessedTraceSource,
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource
errorsTraceSource, System.String defaultCategory, System.Boolean
tracingEnabled, System.Boolean logWarningsWhenNoCategoriesMatch,
System.Boolean revertImpersonation)\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,Trace\r\n
Resolving parameter \"traceListeners\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(System.String
name,
System.Collections.Generic.IEnumerable1[[System.Diagnostics.TraceListener,
System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]] traceListeners,
System.Diagnostics.SourceLevels level, System.Boolean autoFlush,
Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider
instrumentationProvider)\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper,Flat
FileTrace Listener (mapped from System.Diagnostics.TraceListener, Flat
FileTrace Listener)\r\n Resolving parameter
\"wrappedTraceListener\" of constructor
Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper(System.Diagnostics.TraceListener
wrappedTraceListener,
Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator
coordinator)\r\n Resolving
Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener,Flat
FileTrace Listenerimplementation (mapped from
System.Diagnostics.TraceListener, Flat FileTrace
Listenerimplementation)\r\n Calling constructor
Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener(System.String
fileName, System.String header, System.String footer,
Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter
formatter)
And it has this InnerException:
The device is not ready.
How to I can resolve this error?
Read the following article: How to configure and use Microsoft Enterprise Library 5 for logging
This error was from app.config file.
I'd use a same app.config file that has some error.
When I used an app.config that creates with EntLib application, My error resolved.
I added a table in my project which is along these lines:
Table table1 = new Table();
table1.RowGroups.Add(new TableRowGroup());
table1.RowGroups[1].Rows.Add(new TableRow());
TableRow currentRow = table1.RowGroups[1].Rows[1];
When I added the table, to reference it, i added a reference presentationFramework.dll to start using the namespace "System.Windows.Documents". Then it started giving me 3 errors
The type 'System.Windows.Markup.IAddChild' is defined in an assembly that is not referenced. You must add a reference to assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
The type 'System.Windows.IInputElement' is defined in an assembly that is not referenced. You must add a reference to assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
The type 'System.Windows.ContentElement' is defined in an assembly that is not referenced. You must add a reference to assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
I don't understand this. What should I do to correct this error?
Please help me
Add a reference to PresentationCore DLL, which is also in the GAC and is required.
Brian
We have a simple task that, before compiling, makes all of our AssemblyInfo.cs files editable, then updates
[assembly: AssemblyVersion("1.0.0.0")]
to
[assembly: AssemblyVersion("1.0.0.<SourceGetVersion>")]
All of our assemblies are signed using the same key.
This kind of thing is probably fairly standard, and it works just fine, except that it causes test failures.
The failures look like this:
Test method
Namespace.Tests.MessageTest.TestMethod
threw exception:
System.IO.FileLoadException: Could not
load file or assembly
'Namespace.BusinessLayer.BusinessComponent.Documents,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx' or
one of its dependencies. The located
assembly's manifest definition does
not match the assembly reference.
(Exception from HRESULT: 0x80131040)
So, I turned on the logging that was suggested, and get this:
W, 3964, 90, 2010/12/07, 09:57:43.059,
TFSBUILD\QTAgent32.exe, Getting
custom attributes for type
System.Reflection.RuntimeMethodInfo
threw exception (will ignore and use
the reflection way):
System.IO.FileLoadException: Could not
load file or assembly
'Namespace.BusinessLayer.BusinessEntity,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx' or
one of its dependencies. The located
assembly's manifest definition does
not match the assembly reference.
(Exception from HRESULT: 0x80131040)
File name:
'Namespace.BusinessLayer.BusinessEntity,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx' at
System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule
pModule, IRuntimeMethodInfo pCtor,
Byte** ppBlob, Byte* pEndBlob, Int32*
pcNamedArgs) at
System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule
module, IRuntimeMethodInfo ctor,
IntPtr& blob, IntPtr blobEnd, Int32&
namedArgs) at
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule
decoratedModule, Int32
decoratedMetadataToken, Int32
pcaCount, RuntimeType
attributeFilterType, Boolean
mustBeInheritable, IList
derivedAttributes, Boolean
isDecoratedTargetSecurityTransparent)
at
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo
method, RuntimeType caType, Boolean
inherit) at
System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Boolean
inherit) at
Microsoft.VisualStudio.TestTools.Common.ReflectHelper.GetAttributes(MemberInfo
info, Boolean bInherit)
=== Pre-bind state information === LOG: User = domain\tfsbuildAccount
LOG: DisplayName =
Namespace.BusinessLayer.BusinessEntity,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx
(Fully-specified) LOG: Appbase =
file:///D:/Builds/4/10/TestResults/tfsbuildAccount-TFSBUILD
2010-12-07 09_56_54_x86_Debug/Out LOG:
Initial PrivatePath = NULL Calling
assembly :
Namespace.BusinessLayer.BusinessComponent.Edi.Tests,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx.
=== LOG: This bind starts in default load context. LOG: Using application
configuration file:
D:\Builds\4\10\TestResults\tfsbuildAccount-TFSBUILD
2010-12-07
09_56_54_x86_Debug\Out\Namespace.BusinessLayer.BusinessComponent.Edi.Tests.DLL.config
LOG: Using host configuration file:
LOG: Using machine configuration file
from
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference:
Namespace.BusinessLayer.BusinessEntity,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx LOG:
Attempting download of new URL
file:///D:/Builds/4/10/TestResults/tfsbuildAccount-TFSBUILD
2010-12-07
09_56_54_x86_Debug/Out/Namespace.BusinessLayer.BusinessEntity.DLL.
WRN: Comparing the assembly name
resulted in the mismatch: Revision
Number ERR: Failed to complete setup
of assembly (hr = 0x80131040). Probing
terminated.
Now, I may have mixed up the assemblies posting this, but it's the same pattern for all the tests. Mind you, the public keys are all the same, and I can see that all of the revision numbers are the same.
What are we doing wrong?
Try changing the reference assebly to be not version specific. "Secific Version = False" in the properties tab for the assembly.