VS2010 Custom MarkupExtension - visual-studio-2010

We have just switched to vs2010 from vs2008, and our projects compile and run well without any problem. However, the xaml designer has some errors. Here is one of the errors hope someone can provide a solution.
We have a custom MarkupExtension, and we use it in xaml to get certain resources. Something like this:
<Button Style="{l:GetResource Key=MyButtonStyle}" />
I know we can use StaticResource or DynamicResource. However we have our reasons to use the custom markupextension.
The error message from the designer is:
'GetResourceExtension' is not valid for Setter.Value. The only
supported MarkupExtension types are DynamicResourceExtension and
BindingBase or derived types.
My question is that the code works fine in vs2008, and also runs fine in 2010, how to make the 2010 designer work?

I've written a few Markup Extensions and although the code runs I get Xaml Error's like the one you get all the time. Assuming you have valid code I found the only way to get rid of the errors was via the rebuild option and then running the app.
Of course the problem is if you change it again or move it the errors seem to come back. My assumption is the static compile cannot fully resolve whatever your markup is doing and is throwing the error based on this.
In my case I was writing a method binder and because the object was null until runtime I ended up having to use new Object(); and swapping it out at runtime. It's hacky but the compile error were driving me nuts.
The xaml parser seems to be better in 2012 but even then there are the odd errors.

Related

Code injection thorugh Visual Studio 2015, How to remove code for security

I used to develop code injection programs with Visual Studio 2010 (maybe 5 years ago?).
Now I need it again and I developed it pretty much the same as before (with Visual Studio 2015).
However, I have confirmed that the codes I have not seen before are generated.
The first thing I found is the above problem.
It seems that the program's entry point, the address of the function, uses the table without pointing directly to the contents.
The problem is that I can not find the address and size of the injected code.
Is there a way to disable it?
The second problem is that weird functions are added.
My injection code is code that calls CreateProcess, ExitProcess.
However, each address is called immediately after each function is called.
This is the part of 0x013A14CE : CALL test.013A1DA0 above.
The contents of the function are as above.
This problem causes a crash after injecting the code.
I do not know what this is doing, but I think it's code for security.
I found several compile options, but I could not solve the problem.
I tried to compile with Visual Studio 2010, but the result was the same.
Inline assembly seems to be able to solve this problem, but it seems hard to solve it every time there is a fix.
please answer my question

Can't view Application property page - E_FAIL / Method Not Implemented

In the Solution Explorer in Visual Studio 2012, I right click on my wp8 project and go Properties, and the Application tab shows:
An error occurred trying to load the page.
Error HRESULT E_FAIL has been returned from a call to a COM component.
or
An error occurred trying to load the page.
The method or operation is not implemented.
Would anyone know how to go about debugging this?
I cannot repro this problem with a fresh project, but haven't been able to nail out where it is failing in my project...
Maybe related to AssemblyInfo.cs? Source file 'Properties\AssemblyInfo.cs' could not be found
BTW it builds and deploys to my device just fine...
Thanks
So after an exhaustive round of brute force elimination, I was able to narrow this down to my use of .java files. Yes it is weird, but it has worked. I have been including .java files in my project and setting their properties to Compile as c#. There were merge reasons for doing so, and I had of course modified the java code slightly to compile, but somehow Visual Studio's property pages spaz out when a .java file is included this way, even though the project compiles just fine. So I wrote a little tool to copy all the .java files to .java.cs and include them that way and everything is fine now!
I found this issue in all of my projects and reasoned it might have had to do with a recent Windows update. I updated VS 2017 to 15.9.15 and that resolved it for me.

Visual Studio 2010 keeps complaining about Invalid XML although there is none (WP7)

I experience a strange behaviour in Visual Studio 2010 when creating Windows Phone 7 apps. After some time VS starts to complain about Invalid XAML although there is no problem and the app compiles and runs just fine.
It bugges me because I cannot use the visual desingner saying "Exception was thrown on "DataTemplate": Invalid XML" and there is a DataTemplate higlighted in the code. The data template is always ok, VS does not complain about it when copy-pasted to another project.
I found out that problematic are usually the DataTemplates with custom converters or when usin g classes like PhonePerformance.
Sometimes the error is "Exception thrown was due to document error: Invalid XML" and nothing is even highlighted in the XAML file.
I tried reinstalling .NET. Visual Studio etc. and the problem occurs on two separated machines so I do not think it is specific to my configuration. It may be specific to my code.
Anyone experienced similar behaviour?
When using XAML, if you reference a library that needs to be evaluated but can't be at design time you get this kind of error. You can turn off the visual editor and just work in XAML - that will stop the error (and save you time).
You reinstalled .NET and VisualStudio??? You should have just spun up a second instance, opened the solution in both, then attached the debugger from one to the second and opened up the visual editor. It would have told you exactly what in your code was causing the problem. Also DesignerProperties.IsInDesignMode in your converters. Jeez. You wasted so much time :(
As for design time data, that's tricky. Either you have DesignTimeDataWithDesignTimeCreatableTypes that aren't or DesignData that can't create proxies for your real types (for whatever reason, had this issue many times deep in the past).
The only way to figure this out is to debug one instance from another. Its actually not that hard. I do it alot (debugging WF4 ActivityDesigners).
A friend has found a solution and you would not believe where the problem is. This happens if you have a space in the name of your assembly. I found out that I really have a space in assembly name in all the problematic projects, renamed the assemblies and the designer works again.
The solution is also mentioned here http://forums.silverlight.net/t/115011.aspx/1

How to ignore an explicit error in VS2010?

I would like VS2010 to ignore an error in XAML Code. The Reason is, it's not a real error, I have a own class of Windows and VS is not able to create an instance of it. So now it always shows "Can not create an instance of "ChildWindow"". This would not be bad, but it marks the hole file as error, and this looks realy ugly.
So: I would love to tell him to ignore the ChildWindow error, but show other errors, but don't know how.
Thanks for your advice.
EDIT:
To make the things a bit clearer here is a sample of the code:
<cis:ChildWindow ... />
.
.
.
</cis:ChildWindow>
where cis:ChildWindow is derived from UserElement. Now the preview from VS can't create an instance of childWindow and throws an errror. If I build the Project everything is fine.
Does ChildWindow create objects (or have a DataContext) that require external assemblies, hardware drivers, or anything unusually picky?
If so, and if you can find out which object this is through trial and error, sometimes the following works:
bool inDesignMode = System.ComponentModel.DesignerProperties.GetIsInDesignMode(this);
if(!inDesignMode)
InitializePickyDriver();
It's worked for me a few times.
You can right-click on the file in Solution Explorer and choose to Exclude it from the solution. You'll then be able to build your solution and it won't complain about errors in that file.
But that only works if you don't need to use the file to build your solution. If you need the file to be included then I'm not aware of any way to achieve what you want, other than commenting out the lines that are causing a problem (other than the obvious solution, which is to fix the actual problem, but I'm guessing there's a good reason you can't do that).

Lots of type errors in Visual Studio Error List -- until I build and then they are gone

I recently added a new project to my Visual Studio 2008 solution. Now, as I make edits in the new project, I receive a ton (~50) of type checking errors - indicating that an assembly reference may be missing. However, when I actually build the solution, the errors go away. As best I can tell, my dependencies are set and the build order is correct. What could be wrong?
It doesn't prevent me from building and deploying, but it's a major nuisance. It makes it hard to tell when I actually have introduced new errors (until I do compile). Thus, it erodes the usefulness of having the error window do static analysis.
Example, one of the 50 errors is this:
"The type of namespace name 'PersonManager' does not exist in the namespace 'Gideon' (are you missing an assembly reference?"
In reference to this line of code:
Gideon.PersonManager pm = new Gideon.PersonManager()
PersonManager is underlined in both places, and when I right click the type and selected 'find all references' I get an alert box that says "Cannot navigate to PersonManager"
However, the references are definitely there, because when I build, it works.
One other detail is that there is a mixture of C# and VB.net code, though I don't think that should make a difference.
Well, yes, the IntelliSense parser is not an exact replica of the C# compiler. It has a very different job to do, it needs to do something meaningful while the code is utterly broken since you are editing it. Tough assignment, they did a tremendous job with it. But as a side-effect, it can fail to parse things that are actually legal. It's quite rare but not unheard of, seen it myself a few times.
This won't go anywhere concrete until you at least give us some idea of what kind of errors you are seeing, along with a snippet of the code that generates them. You didn't do so, I can only recommend that you select another window so you don't have to look at them.
I had the same problem. I had a project in my solution that was causing the problem - I removed the project from the solution, then added a reference to that project in the main solution and the errors went away. Strange that it only happened on 1 machine. Opening the solution on another machine was fine...

Resources