Swashbuckle custom asset not found - swagger

I added to SwaggerConfig.cs this string
c.CustomAsset("index", thisAssembly, "Table.Web.CustomContent.index.html");
...than I run the application, go to swagger docs and get error:
An error has occurred.
Embedded resource not found - Table.Web.CustomContent.index.html
Swashbuckle.SwaggerUi.AssetNotFound
The build action property of the index.html was set to embedded resource
What should I do to fix it?

I struggled with this for a while today in a ASP.NET C# project and finally resolved it by cobbling together a few different resources.
First (as noted in the Swagger comments), the item must be marked as an Embedded Resource by right-clicking the item in the solution explorer and going to Properties, and selecting Embedded Resource from the Build Action dropdown.
Second, the logical name can be tricky to identify. In my case, a dash in a directory name was being converted to an underscore once embedded, leading to lots of hair-pulling (hair_pulling?). The easiest way to get the true logical path is to get it from the Build Output window.
Go to Tools => Options
Expand the Projects and Solutions sidebar item and click Build and Run
Set the MSBuild Output to Detailed.
Clean the solution and rebuild, opening the Output window if necessary.
The output log should unambiguously state the true logical name of the file with a line like...
Resource file 'swagger-ui\SwaggerUiStyle.css' gets manifest resource name 'MySolutionName.swagger_ui.SwaggerUiStyle.css'
(credit to #bkwdesign for his excellent explanation on this part)

Related

Blazor Server localization

I have a project using Localization. program.cs:
builder.Services.AddLocalization();
...
app.UseRequestLocalization(new RequestLocalizationOptions()
.SetDefaultCulture(LanguageList.GetSupportedLanguages[0])
.AddSupportedCultures(LanguageList.GetSupportedLanguages)
.AddSupportedUICultures(LanguageList.GetSupportedLanguages));
Where LanguageList.GetSupportedLanguages is nothing but an array of CultureInfo.
It's working perfectly; however, I have put the .resx files in the same folder as the razor files and the folder content gets quite messy fast. If I move them, it doesn't work anymore.
I read in Microsoft doc that the Resource file path can be set by:
builder.Services.AddLocalization(config => config.ResourcesPath = "Resources");
However, if I move the resx files to this folder two things happen. It doesn't work (text is not set) and I get this error message:
Custom tool PublicResXFileCodeGenerator failed to produce an output for input file 'Resources\Index.en.resx' but did not log a specific error.
I been trying some tips I found here on StackOverflow, among them adjusting the folder structure to mimic the namespace.
No luck. What am I doing wrong here? How do I utilize the ResourcesPath setting?

Issues with multiple build template (xaml files) in project

I'm having trouble with my TFS Build project. I'm following the example from here as far as setting up the project in VS.
I have a project just for the custom activities and a separate project for just the templates. The issue I have is that the Templates project can only contain one xaml file. If I copy and and paste it in the same project it wont build. I get the following error:
Error 102 The item "obj\Debug\TfsBuild_Process_BeforeInitializeComponentHelper.txt" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
But if I remove it, it'll build just fine. Everything works, meaning it'll build if I queue a build.
I have also tried the solution suggested on here, but it doesn't seem to resolve my issue.
Solution:
Renaming the form name in the solution explorer.
Change the class name in the .cs and Designer.cs file.
Change the constructor and destructor name (which is same as class name)
Change the name space name (if needed).
Here is the link to download the project.
I can't seem to figure out why. Any help is greatly appreciated!
I don't know if you still have this problem but I also had the problem today. I found a resolution that (if you still facing the problem) can help you or others.
When you copy a Build Process template it automaticly gets the x:Class property set to TfsBuild.Process. When you have multiple process templates with the same value then you will get this error when building the project.
<Activity mc:Ignorable="sads sap sap2010" x:Class="TfsBuild.Process" this:Process.BuildNumberFormat="$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)" this:Process.AgentSettings="[New Microsoft.TeamFoundation.Build.Workflow.Activities.AgentSettings() With {.MaxWaitTime = New System.TimeSpan(4, 0, 0), .MaxExecutionTime = New System.TimeSpan(0, 0, 0), .TagComparison = Microsoft.TeamFoundation.Build.Workflow.Activities.TagComparison.MatchExactly}]" this:Process.Verbosity="[Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal]" this:Process.OutputFullHistory="True" this:Process.OutputBranchOrigin="True" this:Process.OnlyOutputChangedFiles="True" this:Process.StartChangeset="0"......
I solved the problem by replacing TfsBuild.Process with another name for every template (ex. TfsBuild.ProcessLabDefault). Please note you should also change all the instances of this:Process because the two are linked together (ex. this:ProcessLabDefault).
<Activity mc:Ignorable="sads sap sap2010" x:Class="TfsBuild.MyProcess" this:MyProcess.BuildNumberFormat="$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)" this:MyProcess.AgentSettings="[New Microsoft.TeamFoundation.Build.Workflow.Activities.AgentSettings() With {.MaxWaitTime = New System.TimeSpan(4, 0, 0), .MaxExecutionTime = New System.TimeSpan(0, 0, 0), .TagComparison = Microsoft.TeamFoundation.Build.Workflow.Activities.TagComparison.MatchExactly}]" this:MyProcess.Verbosity="[Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal]" this:MyProcess.OutputFullHistory="True" this:MyProcess.OutputBranchOrigin="True" this:MyProcess.OnlyOutputChangedFiles="True" this:MyProcess.StartChangeset="0"......
I didn't find a way to change this by using the interface, View Code & Find and replace works. Hope it helps.
I used the following approach and it worked very well. All that needs replaced is TfsBuild in two locations on the first line of the raw xaml.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/d3fb6b89-b711-4a02-a10a-a88a0cb4f714/unable-to-add-more-than-one-templatexaml-into-activity-library-workflow-project?forum=tfsprocess
From the link:
1 Right-click your Copy of DefaultTemplate.xaml in Source Control and select View With… to open it in Notepad (you can also right-click the template in VS and select 'View Code').
2 Then in the first line change:
**x:Class="TfsBuild.Process"** to **x:Class="YourProcessTemplateName.Process"**
**xmlns:this="clr-namespace:TfsBuild"** to **xmlns:this="clr-namespace:YourProcessTemplateName"**
I ran in to this problem and wanted to add the solution I found to it. If you check the properties of the XAML files, when you link them to your project they're assigned a BuildAction of XamlAppDef. Changing this to 'Content' will resolve the error.
To find the properties screen you need to edit just highlight the XAML file in Solution Explorer and either hit F4 or Right-Click on the file and choose 'Properties' from the context menu.
Hope this helps.

Attributes from MvxBindingAttributes are not added with MvvmCross

I have the MvxBindingAttributes.xml in my UI.Droid/Resources/Values but everytime I try to use the bindings in my layouts I get
Warning attribute is not declared.
No resource identifier found for attribute 'MvxBind' in package
'DroidUI'
so for some reason it cannot find those attributes. I have tried to close/reopen/clean/rebuild with no luck, tried removing the layouts and then building (Hoping it would add them at build) and then try to add them again, but nothing seems to work
Have you checked that the MvxBindingAttributes.xml file is marked in properties as an AndroidResource?
VisualStudio likes marking the xml files as content or none instead - especially if you've added the MvxBindingAttributes.xml file as a link.
As an update to this, you can also now use a special 'auto' xml scheme:
xmlns:local="http://schemas.android.com/apk/res-auto"
In the project properties, add a Android Manifest file and add a package name that contains at least two periods, for example:
com.DroidUI
In the axml file, type the package name instead of the namespace:
xmlns:local="http://schemas.android.com/apk/res/com.DroidUI
xmlns:local="http://schemas.android.com/apk/res-auto
Fixed it for me.
First, thanks for the answer. I had the same problem.
But in my case, attempting to use the suggestions above failed. or at least that is what i thought.
When i used local:MvxItemTemplate=#layout/My_Manifest while i had the My_Manifest.axml file correctly placed in Layout folder, and correct xml schemas, it still had problems.
But, when i changed My_Manifest to my_manifest while leaving the actual file name as My_Manifest.axml, everything was working.
just wanted to share
In my case for some reason the MvxBindingAttributes.xml file existed, but hadn't been included in the project. Right-clicking on MvxBindingAttributes.xml and choosing "Include in Project" sorted the problem for me.
Just in case: You might also have rubbish (in my case, it were dots) in some of your XML. But the error pointed "Maybe there's something wrong with the auto-generated XML lol" so it took me half an hour to notice it... Sigh!

The resource type 'XXXX.XXX' does not have a publicly visible static property named '_RequiredXXXX'

"'ErrorMessageResourceType' property specified was not found."
{"The resource type 'XXXX.XXXXXX' does not have a publicly visible static property named '_RequiredXXXX'."}
I'm getting this error when my Create.aspx view is called and steps over that line:
<%=Html.TextBoxFor(Function(model) model.NO_DEMND, New With {.class = "txtbox", .disabled = True})%>
<%=Html.ValidationMessageFor(Function(model) model.NO_DEMND)%>
The message is there in the Ressources file, I think the problem is deeper than that but i'm having a hard time finding it. It pops this error very early on the ASPX page. It's the first model component it goes thru, i tried removing this one and it's the same message for all the model.xxxx components. I guess it's an error somewhere in the linkage. The .EDMX is correct and I get no build errors, can anyone enlight me ?
Thanks alot
Tom.
Found the answer, turns out we had the same bug last year working on this project.
I'll add the answer for the sakes of knowledge and sO :-)
Right click on the affected Resources file to get the properties.
Set those values:
Build Action: Embedded Resource
Custom Tool: PublicResXFileCodeGenerator
Custom Tool Namespace: Resources
Hope it helps anyone in the near futur since it took me 4hrs to figure this out...
Tom.
Changing the build action property of my resource file to content resolved the error

How do I fix 'Setup project with custom action file not found' exception?

I am trying to create a setup project for a Windows Service. I've followed the directions at http://support.microsoft.com/kb/816169 to create the setup project with no trouble.
I want to be able to get a value during the installation in order to update the app.config with the user's desired settings. I added a Textboxes (A) dialog to retrieve the values. I set the Edit1Property property to "TIMETORUN", and in my Primary Output action's CustomActionData property I put in the following: /TimeToRun="[TIMETORUN]\". So far so good. Running the setup I can retrieve the TimeToRun value from the Context.Parameters collection without issue.
In order to locate the app.config I need to also pass in the value of the TARGETDIR Windows Installer Property to my custom action. This is where things begin to fall apart. In order to achieve this, the above CustomActionData must be altered like so: /TimeToRun="[TIMETORUN]\" /TargetDir="[TARGETDIR]\". Now when I run the setup I get the following error message:
Error 1001. Exception occurred while initializing the installation.
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\SysWOW64\Files' or one of its dependencies. The system cannot
find the file specified.
If you google this problem you will inevitably find people having tremendous success by simply adding the trailing slash to the /TargetDir="[TARGETDIR]\" portion of the CustomActionData. This unfortunately does not solve my issue.
I tried so many different variations of the CustomActionData string and none of them worked. I tried logging to a file from my overridden Install method to determine where the breakage was, but no log file is created because it's not even getting that far. As the error indicates, the failure is during the Initialization step.
I have a hunch that it could be one of the dependencies that the setup project is trying to load. Perhaps somehow something is being appended to the CustomActionData string and isn't playing well with the TARGETDIR value (which contains spaces, i.e. "C:\Program Files\My Company\Project Name"). Again, this is another hunch that I cannot seem to confirm due to my inability to debug the setup process.
One further thing to mention, and yes it's another hunch, could this be an issue with Setup Projects on 64-bit version of Windows? I'm running Windows 7 Professional.
I'll provide names of the dependencies in case it helps:
Microsoft .NET Framework
Microsoft.SqlServer.DtsMsg.dll
Microsoft.SqlServer.DTSPipelineWrap.dll
Microsoft.SqlServer.DTSRuntimeWrap.dll
Microsoft.SQLServer.ManagedDTS.dll
Microsoft.SqlServer.msxml6_interop.dll
Microsoft.SqlServer.PipelineHost.dll
Microsoft.SqlServer.SqlTDiagM.dll
As you may glean from the dependencies, the Windows Service is scheduling a call to a DTSX package.
Sorry for the long rant. Thanks for any help you can provide.
The answer is so maddeningly simple. If the last argument in the CustomActionData is going to contain spaces and thus you have to surround it with quotes and a trailing slash, you must also have a space following the trailing slash, like this:
/TimeToRun="[TIMETORUN]\" /TargetDir="[TARGETDIR]\ "
The solution and explanation can be found here.
Had a similar issue. In my case, it was odd because my installer had ran successfully once, then I uninstalled my app via Add/Remove Programs successfully, did some coding (did NOT touch my CustomActionData string), and rebuilt my project and setup project. It was when I re-ran my MSI that I got this error.
The coding I had done was to bring in more values of more parameters I had been specifying in my CustomActionData string. That syntax for getting the parameter values (i.e. string filepath = Context.Paramenters["filepath"]), which was in my Installer class, was actually fine, but as I found out, the syntax of the later parameters I was now trying to get from my CustomActionData string had not been correct, from the very beginning. I had failed to add a second quote around one of those parameters, so nothing else could be obtained.
I was using the "Textboxes (A)" and "Textboxes (B)" windows in the User Interface section. A has 1 box, EDITA1, where I get the path to a file, and B has 2 boxes, EDITB1 and EDITB2, for some database parameters. My CustomActionData string looked like this:
/filepath="[EDITA1]" /host="[EDITB1] /port="[EDITB2]"
It should have been:
/filepath="[EDITA1]" /host="[EDITB1]" /port="[EDITB2]"
(closing quote on [EDITB1])

Resources