PreMailer "Method Not Found" (AngleSharp.Dom.IElement.RemoveAttribute) - c#

I have this code which inlines CSS using PreMailer;
PreMailer.Net.PreMailer cleanser = new PreMailer.Net.PreMailer(htmlString);
PreMailer.Net.InlineResult result = cleanser.MoveCssInline(ignoreElements: ".ignore");
return result.Html
But I'm getting this exception:
Method not found: 'Void AngleSharp.Dom.IElement.RemoveAttribute(System.String)'
Stack Trace
[MissingMethodException: Method not found: 'Void AngleSharp.Dom.IElement.RemoveAttribute(System.String)'.]
PreMailer.Net.StyleClassApplier.ApplyStyles(IElement domElement, StyleClass clazz) +0
PreMailer.Net.StyleClassApplier.ApplyAllStyles(Dictionary`2 elementDictionary) +125
PreMailer.Net.PreMailer.MoveCssInline(Boolean removeStyleElements, String ignoreElements, String css, Boolean stripIdAndClassAttributes, Boolean removeComments) +241
The answer is probably really obvious but I'm just not clicking on.
AngleSharp: v0.9.9
PreMailer: v1.5.4

There has been an update released for PreMailer. Upgrade to 1.5.5 to resolve this issue! No rollback for AngleSharp required!

Related

c# commandline no error line number

If there is an exception in .NET code and and PDB file is available you normally get the errors with source code line numbers shown in the exception message. This seems to be different in command line executables, where I do not get any line number although a PDB file is available:
Anwendung: MNX.CommandLine.EpkFtpEventhandler.exe Frameworkversion: v4.0.30319 Beschreibung: Der Prozess wurde aufgrund eines Ausnahmefehlers beendet. Ausnahmeinformationen: System.Data.SqlClient.SqlException Stapel: bei System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(System.String, Boolean, Int32, Boolean) bei System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(System.Threading.Tasks.TaskCompletionSource`1, System.String, Boolean, Int32, Boolean) bei System.Data.SqlClient.SqlCommand.ExecuteNonQuery() bei MNX.DB.WriteLocal(System.String) bei MNX.DB.Write(System.String) bei MNX.CommandLine.EpkFtpEventHandler.Main(System.String[])
Does anyone know why?
Use Stack Frames and surround you code with a try catch:
try
{
throw new Exception();
}
catch (Exception ex)
{
// Get stack trace for the exception with source file information
var st = new StackTrace(ex, true);
// Get the top stack frame
var frame = st.GetFrame(0);
// Get the line number from the stack frame
var line = frame.GetFileLineNumber();
// Print the line number
Console.WriteLine($"An Error ({ex.Message}) occurred in line {line}");
}
To avoid plagiarism: I got the idea from this question.
I don't know why it isn't normally displayed in your console application though, but this should do it as well.
Try to empty symbol cache by accessing Debug > Options > Debugging > Symbols and clean your solution afterwards.
Exception.StackTrace gave back the line number, when it comes from a catch. Strangely only when I catch the exception, not when it's thrown without being catched.

TFS Git build breaks after updating build definition

Our TFS build has broken following updating the XAML build definition. Changes included modifying the template and a few parameters. The trace is below
TF215097: An error occurred while initializing a build for build definition [REDACTED]:
Exception Message: Cannot set unknown member 'Microsoft.TeamFoundation.Build.Activities.Git.GitPull.CheckoutSubmodules'. (type XamlObjectWriterException)
Exception Stack Trace: at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
at System.Activities.XamlIntegration.FuncFactory`1.Evaluate()
at System.Activities.DynamicActivity.OnInternalCacheMetadata(Boolean createEmptyBindings)
at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings, IList`1& validationErrors)
at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity, ChildActivity& nextActivity, Stack`1& activitiesRemaining, ActivityCallStack parentChain, IList`1& validationErrors, ProcessActivityTreeOptions options, ProcessActivityCallback callback)
at System.Activities.ActivityUtilities.ProcessActivityTreeCore(ChildActivity currentActivity, ActivityCallStack parentChain, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
at System.Activities.Validation.ActivityValidationServices.InternalActivityValidationServices.InternalValidate()
at Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.ValidateWorkflow(Activity activity, ValidationSettings validationSettings)
at Microsoft.TeamFoundation.Build.Hosting.BuildProcessCache.LoadFromXaml(String workflowXaml, TextExpressionImports textExpressionImports)
at Microsoft.TeamFoundation.Build.Hosting.BuildControllerWorkflowManager.PrepareRequestForBuild(WorkflowManagerActivity activity, IBuildDetail build, WorkflowRequest request, IDictionary`2 dataContext)
at Microsoft.TeamFoundation.Build.Hosting.BuildWorkflowManager.TryStartWorkflow(WorkflowRequest request, WorkflowManagerActivity activity, BuildWorkflowInstance& workflowInstance, Exception& error, Boolean& syncLockTaken)
The build fails in the first few seconds as this is the process that is trying to retrieve the source. However, I cannot come to any conclusions as to why this error is happening. A Google search doesn't bring up anything useful.
TFS version 2013
Has anyone encountered this error and if so how did you fix it?
If I need to provide more information please ask.
When you modify the Build process template and therefore it’s no longer in sync with the build definition you may get TF215097 error.
#jessehouwing's suspicion makes sense. I can't find too many articles to elaborate this issue, but in this MSND documentation mentions, if you want to edit a custom template, You must use only Visual Studio 2013 to edit your build process templates of TFS 2013.

NotImplementedException in msdeploy when using useChecksum

I am struggling with msdeploy (AKA web deploy) to deploy applications.
I am using the msdeploy .NET classes, no command line. As soon as I specify the UseCheckSum parameter (whether true or false), it throws me a NotImplementedException.
Here is the stacktrace if any msdeploy developer is around :
[NotImplementedException: The method or operation is not implemented.]
[DeploymentException: (27.11.2013 11:30:50) An error occurred when the request was processed on the remote computer.]
Microsoft.Web.Deployment.StatusThreadHandler.CheckForException() +67
Microsoft.Web.Deployment.StatusThreadHandler.Close() +37
Microsoft.Web.Deployment.AgentClientProvider.RemoteDestSync(DeploymentObject sourceObject, DeploymentSyncContext syncContext, Nullable`1 syncPass) +1966
Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId) +306
Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions) +2692
Microsoft.Web.Deployment.DeploymentObject.SyncTo(String provider, String path, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions) +99
Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentWellKnownProvider provider, String path, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions) +101
Microsoft has acknowledged that this is a bug in version 3.5 (and possibly earlier releases too). The useCheckSum flag is incompatible with other command line arguments, such as setParamFile and verbose.
Details can be found on this page: http://forums.iis.net/t/1184709.aspx?+useChecksum+and+whatif+BUG+.

Unity error--- Activation error occured while trying to get instance of type IUserRepository, key ""

I am trying to run MVC sample project Shrinkr downloaded from codeplex
I actually opened this solution in VS2012 and is compiling successfully. But when I run this application ,I am getting this error .
I am getting an exception error message stating "Activation error occured while trying to get instance of type IUserRepository, key ""
"
Pasted below is the detailed exception message
Microsoft.Practices.ServiceLocation.ActivationException was unhandled by user code
HResult=-2146233088
Message=Activation error occured while trying to get instance of type IUserRepository, key ""
Source=Microsoft.Practices.ServiceLocation
StackTrace:
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
at Shrinkr.Web.CreateDefaultUsers.ExecuteCore(IServiceLocator serviceLocator) in c:\Users\RON\Downloads\Shrinkr\Shrinkr.Web.Common\BootstrapperTask\CreateDefaultUsers.cs:line 19
at System.Web.Mvc.Extensibility.BootstrapperTask.Execute(IServiceLocator serviceLocator)
at System.Web.Mvc.Extensibility.Bootstrapper.Execute()
at System.Web.Mvc.Extensibility.ExtendedMvcApplication.Application_Start()
InnerException: Microsoft.Practices.Unity.ResolutionFailedException
HResult=-2146233088
Message=Resolution of the dependency failed, type = "Shrinkr.Repositories.IUserRepository", name = "". Exception message is: The current build operation (build key Build Key[Shrinkr.Infrastructure.EntityFramework.UserRepository, null]) failed: The parameter databaseFactory could not be resolved when attempting to call constructor Shrinkr.Infrastructure.EntityFramework.UserRepository(Shrinkr.Infrastructure.EntityFramework.IDatabaseFactory databaseFactory, Shrinkr.Infrastructure.EntityFramework.IQueryFactory queryFactory). (Strategy type BuildPlanStrategy, index 3)
Source=Microsoft.Practices.Unity
TypeRequested=IUserRepository
StackTrace:
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name)
at Microsoft.Practices.Unity.UnityContainerBase.Resolve(Type t)
at System.Web.Mvc.Extensibility.Unity.UnityAdapter.DoGetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
InnerException: Microsoft.Practices.ObjectBuilder2.BuildFailedException
HResult=-2146233088
Message=The current build operation (build key Build Key[Shrinkr.Infrastructure.EntityFramework.UserRepository, null]) failed: The parameter databaseFactory could not be resolved when attempting to call constructor Shrinkr.Infrastructure.EntityFramework.UserRepository(Shrinkr.Infrastructure.EntityFramework.IDatabaseFactory databaseFactory, Shrinkr.Infrastructure.EntityFramework.IQueryFactory queryFactory). (Strategy type BuildPlanStrategy, index 3)
Source=Microsoft.Practices.ObjectBuilder2
BuildKey=Build Key[Shrinkr.Infrastructure.EntityFramework.UserRepository, null]
ExecutingStrategyIndex=3
ExecutingStrategyTypeName=BuildPlanStrategy
StackTrace:
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
InnerException: System.InvalidOperationException
HResult=-2146233079
Message=The parameter databaseFactory could not be resolved when attempting to call constructor Shrinkr.Infrastructure.EntityFramework.UserRepository(Shrinkr.Infrastructure.EntityFramework.IDatabaseFactory databaseFactory, Shrinkr.Infrastructure.EntityFramework.IQueryFactory queryFactory).
Source=Microsoft.Practices.ObjectBuilder2
StackTrace:
at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForResolutionFailed(Exception inner, String parameterName, String constructorSignature, IBuilderContext context)
at BuildUp_Shrinkr.Infrastructure.EntityFramework.UserRepository(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
InnerException: Microsoft.Practices.ObjectBuilder2.BuildFailedException
appreciate your suggestions to make it working
Strictly I'm not sure what problem it is, according to my experience, if you download a stable sample but unable to run it,mostly it could be reference problem.
So, you may check is that missing any DLL files and make sure their path is Asset/Plugins. Then, check Edit-ProjectSettings-Player-YourTargetPlatform-OtherSettings, confirm that Api Compatibility Level is set to .NET2.0(default is the subset).
Hope it works, good luck :)

RedirectFromPage do not work with special chars in the ReturnUrl

I am working on a form based auth module for MS SQL reporting Services which is described here:
So far so good, but I run into this problem.
The URL I call redirect to the login page to authenticate and then the page redirect back to the return url.
URL sample call:
http://thor/ReportServer/Pages/ReportViewer.aspx?%2fSampleUserReport&rs:Command=Render
This line crash:
FormsAuthentication.RedirectFromLoginPage(m_username, false);
Exception:
System.Web.HttpException: Der für die Umleitung von Anforderungen angegebene Rückgabe-URL ist ungültig.
bei System.Web.Security.FormsAuthentication.GetReturnUrl(Boolean useDefaultIfAbsent)
bei System.Web.Security.FormsAuthentication.GetRedirectUrl(String userName, Boolean createPersistentCookie)
bei TQsoft.Windows.Products.SSRS.Authentication.Logon.ServerBtnLogon_Click(Object sender, EventArgs e)
So after investigating and debugging I found out if I skip &rs:Command=Render it works.
So the only special char in there I can imagine making problem is the : char.
Any idea how to make it work since reporting services are working with those in the navigation a lot.
UPDATE
It turns out that I have to redirect myself like this:
Response.Redirect(Request.QueryString["ReturnUrl"].Replace(":","%3A"));
Context.ApplicationInstance.CompleteRequest();
But this throws another exception:
System.Threading.ThreadAbortException: Der Thread wurde abgebrochen.
bei System.Threading.Thread.AbortInternal()
bei System.Threading.Thread.Abort(Object stateInfo)
bei System.Web.HttpResponse.End()
bei System.Web.HttpResponse.Redirect(String url, Boolean endResponse)
bei System.Web.HttpResponse.Redirect(String url)
bei TQsoft.Windows.Products.SSRS.Authentication.Logon.ServerBtnLogon_Click(Object sender, EventArgs e)
I am really a rookie on asp.net, but start to hate it while RoR wins atm to me.
I had this issue before but with hebrew char that I wanted to pass using URL link.
Try to convert the char using %3A.
Edit
I use Google translate to convert those chars: just write the chars/String, hit translate and copy the relevant part in the URL.
Response.Redirect(HttpServerUtility.UrlEncode(Request.QueryString["ReturnUrl"]));
does this work for you, replacing characters such as a question mark (?), ampersand (&), slash mark (/), and spaces.
http://msdn.microsoft.com/it-it/library/zttxte6w.aspx

Categories

Resources