The "VSCTCompiler" task failed unexpectedly with OutOfMemoryException - visual-studio

What I did is:
I created a new VSIX Project from the Extensibility Template.
I added a new Item for ToolWindow1.
Then I compiled and got the message. It is on Visual Studio 2015.
Memory on computer is 8GB and Visual Studio is installed on brand new computer.
The message I got is as follows:
Severity Code Description Project File Line Suppression State
Error The "VSCTCompiler" task failed unexpectedly.
System.OutOfMemoryException: Out of memory.
at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
at Microsoft.VisualStudio.CommandTable.BitmapItem.Read(TextReadVSCTCStream s, XmlElement itemNode)
at Microsoft.VisualStudio.CommandTable.ItemList.Read(TextReadVSCTCStream s, XmlElement listNode)
at Microsoft.VisualStudio.CommandTable.CommandTable.ReadCMDSSection(TextReadVSCTCStream s, XmlElement listNode)
at Microsoft.VisualStudio.CommandTable.CommandTable.Read(TextReadVSCTCStream s)
at Microsoft.VisualStudio.CommandTable.CommandTable.Read(String fileName, ReadOptions ro, IMessageProcessor errorProcessor)
at Microsoft.VisualStudio.CommandTable.CommandTable.Read(String fileName, IMessageProcessor errorProcessor)
at Microsoft.VisualStudio.CommandTable.Compiler.Compile()
at Microsoft.VisualStudio.CommandTable.VSCTCompiler.Execute() VSIXProject1
Is there any way out on this?

It seems that the File created by Visual Studio is corrupted. You can check the file yourself in the File Explorer in the Folder "/Resources" (which should lie next to your .csproj file) and try to open it with another program.
To fix the error, replace the file with a valid .png file. For me it worked by creating a new "ItemTemplate" Project from the Extensibility Templates. Then Add Item -> Custom Command.
This created a valid .png, which can be used to replace the corrupt .png file from the VSIX Project.
Solution found here: https://dotblogs.com.tw/rainmaker/2016/08/23/132552.
If you cannot speak Korean, here is the google translation: https://translate.google.at/translate?hl=de&sl=zh-TW&u=https://dotblogs.com.tw/rainmaker/2016/08/23/132552&prev=search

Related

Copy Content Files from VS 2017 to Windows 10 IoT Core for Raspberry Pi 3

I am developing an application for Windows Core for Raspberry Pi 3 using Visual Studio 2017 Community Edition.
I am quite new to the platform and trying to copy some content files to Raspberry.
I have tried changing the type of my files to "Content" and "Copy Always" in the property window.
However, I am not able to find where these files are copied and how can I refer these files in my code.
Any help would be greatly appreciated.
However, I am not able to find where these files are copied and how
can I refer these files in my code.
You can get the path like this:
Windows.Storage.StorageFolder installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
And access these files like this:
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///copyfile test.txt"));
string text = await Windows.Storage.FileIO.ReadTextAsync(file);
For more information you can reference "File access permissions" and "Create, write, and read a file".

Private extension galleries error "A connection to the server could not be established [...]"

Added a private VS extension gallery as described in
https://msdn.microsoft.com/en-us/library/hh266746.aspx
using an atom feed as described in
https://msdn.microsoft.com/en-us/library/hh266717.aspx
And got this error message:
"A connection to the server could not be established because the following error(s) occurred:
Could not determine the protocol used for this gallery. The URL must point to an Atom Feed or SharePoint List configured for hosting Visual Studio Extensions.
Please click here to retry the request."
This guy had the same problem but didn't bother to post his solution (and apparently you can't reply once it's "solved"), so here it goes:
Open up the atom.xml file with Notepad++ then check "Encode in UTF-8" under "Encoding".
In the two places where there's an id after the name of the extension and 2 dots replace that id with the one from your project's Guids class. It's the first GUID in there. Alternatively you could open up the vsix file with WinRar / 7Zip and open up the extension.vsixmanifest file there (the GUID is found on top of this file).
Edit: the 2nd id tag should just include the ID and not the name of the project and the two dots - otherwise updating the extension won't work
Remove all those hyphens - in the atom.xml file in the case that you copied that from the example in https://msdn.microsoft.com/en-us/library/hh266717.aspx
The first GUID on top of the atom.xml file (the one after uuid) can be any GUID you'd like to have (create one under Visual Studio's Tools->Create GUID).

Using ClickOnce exe as a Visual Studio external tool

I have a command line executable I built which is published on the network via ClickOnce. The main use of this tool is through Visual Studio as an external tool. When I set this up in Visual Studio I am able to set the command path to the shortcut under roaming data for my profile.
However, Visual Studio resolves this to a path such as:
C:\Users\ME\AppData\Local\Apps\2.0\CGR50YPV.W5E\RXBXM176.HH8\crea..tion_f423fce0316e1dfa_0001.0000_adecafbe6c6acba3\MyAppp.exe
So what happens is if I launch the exe and grab a new version, Visual Studio is still pointing at the old version (as indicated above). I can fix this by re-pointing the command value of my external tool to the shortcut of my exe, but this is a bit frustrating to deal with.
How can I make this work without having to update my command path every time?
You shouldn't access a ClickOnce application via the exe file. If you're going to do that, just xcopy the \bin folder of the application to the other machine. If you want to use the update features, you should always invoke the ClickOnce application by using the shortcut or by invoking the link to the deployment manifest on the webserver. (The deployment manifest is the application file). You can do a process.start on that link.
[edit -- add new info]
Ohhhhh, so you're accessing the shortcut in the folder under the user's profile? Am I getting that? Instead of looking for that one, can you point to the shortcut on the start menu? It will add one automatically when the user installs the application, if the application is online/offline. The shortcut is added to the start menu to the location of the Publishing Company / Product Name using those fields from the Options dialog.
I do this by setting the assembly information to the same values, and retrieving the assembly information programmatically. I always set the assembly description to be identical to the product name, and the assembly company to be the same as the publishing company. Then I can do this:
Assembly code = Assembly.GetExecutingAssembly();
string company = string.Empty;
string description = string.Empty;
if (Attribute.IsDefined(code, typeof(AssemblyCompanyAttribute)))
{
AssemblyCompanyAttribute ascompany =
(AssemblyCompanyAttribute)Attribute.GetCustomAttribute(code,
typeof(AssemblyCompanyAttribute));
company = ascompany.Company;
}
if (Attribute.IsDefined(code, typeof(AssemblyDescriptionAttribute)))
{
AssemblyDescriptionAttribute asdescription =
(AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(code,
typeof(AssemblyDescriptionAttribute));
description = asdescription.Description;
}
if (company != string.Empty && description != string.Empty)
{
string shortcutName =
string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
\", company, "\\", description, ".appref-ms");
}
(Sorry, I can't figure out how to make the code format prettier and show the indents properly, but you get the idea.)

Embedded Resource missing in Visual Studio 2010 when name ends with "No.xxx"

I've come across a strange behaviour in Visual Studio 2010.
When using embedded resources (files which are added to my C# project and for which the Build Action property is set to Embedded Resource), the files are included in the output assembly as binary data. Listing the resources is straightforward:
class Program
{
static void Main(string[] args)
{
string[] names = typeof (Program).Assembly.GetManifestResourceNames ();
foreach (var name in names)
{
System.Console.Out.WriteLine (name);
}
}
}
However, if the embedded resource file name ends with No.xxx (the extension is irrelevant), the file does not show up in the list. I cannot figure out any reason why Visual Studio 2010 would not include such a file. What did I miss?
Note: if I rename the embedded resource file in the solution explorer to something else, then everything works as expected.
Dan from the Microsoft Connect team has finally provided a valid explanation for this behaviour:
Hello, thanks for the report, this is actually working normally. The reason is that any resx files whose names match the pattern .VALIDCULTURE.resx are assumed to be specific to that culture. (This is how it has worked since VS2002, for better or worse)
In your case "no" is a valid culture (Norwegian, I guess) so the build process builds it into a satellite assembly. Here's what I got when I tried this. Note the "no" subfolder. If in your app you change your current culture to Norwegian, the resource load will load this set of resources.
So the problem has nothing to do with the word No itself, but rather with the fact that it is a valid, two-letter, culture name (in my case Norwegian). I checked, and indeed, there was a sub-folder in bin\Debug named No, containing a satellite assembly named Project.resources.dll in it.
Renaming the resource to end with .EN.xxx or .FR.xxx does, of course, exhibit the same behaviour.
As of MSBuild 16.9 you can include files like these by setting the WithCulture property to "false", as pointed out by #reduckted :-)
<EmbeddedResource Include="Resources.en.xml" WithCulture="false" />

XNA Framework Importers

I am working on a game using the XNA framework. My game has several levels which I am storing the data in a plain old text file. In VS 2008 when I add the level file to the project and compile, I receive the following error message.
Error 1 Cannot autodetect which importer to use for "Levels\0.txt". There are no importers which handle this file type. Specify the importer that handles this file type in your project. F:\Projects\BrickBreaker\BrickBreaker\Content\Levels\0.txt BrickBreaker
The reason I am bringing this out is because if I change on of my levels and run the game, the level is not updated. I have found that the level is not updated because VS runs the game from the bin\debug folder and since the level files are not included in the project, they are not copied when they change. I also found that the platform sample that comes with the framework includes the level data in the project, that's where I got the technique from.
So, should I use a different file format or just deal with having to manually copy the new level files over?
Resolution - After digging into the answers on this post I found a solution. I added the text files to the project and set the build property to none. The error no longer occurs when compiling and the file is included in the project.
You can have Visual Studio just copy over the files if you want to the output directory. Under the properties of the text file in the project, choose Build Action: None and change the copy to output directory to as needed.
You can also check out the platformer sample. They use text files as their level format.
There is no content importer for text files. Ignore the content pipeline and just read the file in just as you would any other normal text file.
string line = string.empty;
using(StreamReader sr = new StreamReader("filename")){
while((line = sr.ReadLine()) != null){
//reads line by line until eof
//do whatever you want with the text
}
}
I had similar problem, and found it easier to have the files added to content project, and build action set to none, than to skip content pipeline altogether.

Resources