I am just getting started with windows work flow foundation but whenever I double click an activity in visual studio 2013, expecting the designer to appear i get the following exception.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetExports(ImportDefinition definition)
at System.ComponentModel.Composition.Hosting.DirectoryCatalog.<>c__DisplayClass3.<GetExports>b__2(ComposablePartCatalog catalog)
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InternalGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.InnerCatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.AggregateExportProvider.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.CompositionContainer.GetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.TryGetExportsCore(ImportDefinition definition, AtomicComposition atomicComposition, IEnumerable`1& exports)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports(ImportDefinition definition, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportsCore(Type type, Type metadataViewType, String contractName, ImportCardinality cardinality)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueCore[T](String contractName, ImportCardinality cardinality)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueOrDefault[T](String contractName)
at System.ComponentModel.Composition.Hosting.ExportProvider.GetExportedValueOrDefault[T]()
at Microsoft.VisualStudio.Activities.WorkflowDesignerExtensionManager.InternalGetExtension[T]()
Any Ideas of how to fix this?
Thanks
I updated my visual studio and included both LightSwitch and Microsoft Office Developer tools in the install, and that fixed it.
Related
I have mobile applicaction using Xamarin Forms. I have also library something.framework written in Objective-C and sample project in XCode.
I need to use this library in cross-platform application. I have added native reference to this library at Xamarin.iOS project. I use dependency interface to manage button's action from Xamarin Forms into Xamarin-iOS. The thing is that Visual Studio is not connecting native reference to library with my code in class. Using directive is not accessing native library so I have many errors when I try to use methods form library. I have already read Microsoft's instructions about binding native libraries but not answers came.
How to solve this?
Here are logs from terminal when I have used Objective Sharpie:
Johns-Mac-mini:~ johnmiller$ sharpie bind
-output=InfColorPickerCustom -namespace=InfColorPickerCustom ~/Desktop/InfColorPicker/InfColorPicker/*.h -sdk=iphoneos12.1 Parsing 8 header files... In file included from /var/folders/_g/mb3qv73j16d_mdwzb8bf5hww0000gn/T/tmp765fc04f.h:2: /Users/johnmiller/Desktop/InfColorPicker/InfColorPicker/InfColorIndicatorView.h:19:1: warning: no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed [-Wobjc-property-no-attribute] #property (nonatomic) UIColor* color; ^ /Users/johnmiller/Desktop/InfColorPicker/InfColorPicker/InfColorIndicatorView.h:19:1: warning: default property attribute 'assign' not appropriate for non-GC object [-Wobjc-property-no-attribute] In file included from /var/folders/_g/mb3qv73j16d_mdwzb8bf5hww0000gn/T/tmp765fc04f.h:3: In file included from /Users/johnmiller/Desktop/InfColorPicker/InfColorPicker/InfColorPicker.h:60: /Users/johnmiller/Desktop/InfColorPicker/InfColorPicker/InfColorPickerController.h:28:1: warning: no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed [-Wobjc-property-no-attribute] #property (nonatomic) UIColor* sourceColor; ^ /Users/johnmiller/Desktop/InfColorPicker/InfColorPicker/InfColorPickerController.h:28:1: warning: default property attribute 'assign' not appropriate for non-GC object [-Wobjc-property-no-attribute] /Users/johnmiller/Desktop/InfColorPicker/InfColorPicker/InfColorPickerController.h:29:1: warning: no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed [-Wobjc-property-no-attribute] #property (nonatomic) UIColor* resultColor; ^ /Users/johnmiller/Desktop/InfColorPicker/InfColorPicker/InfColorPickerController.h:29:1: warning: default property attribute 'assign' not appropriate for non-GC object [-Wobjc-property-no-attribute]
Binding... [write] ApiDefinitions.cs [write] StructsAndEnums.cs
Binding Analysis: Automated binding is complete, but there are a few APIs which have been flagged with [Verify] attributes. While the entire binding should be audited for best API design practices, look more closely at APIs with the following Verify attribute hints:
ConstantsInterfaceAssociation (200 instances):
There's no foolproof way to determine with which Objective-C interface an extern variable declaration may be associated. Instances of these are bound as [Field] properties in a partial interface into a nearby concrete interface to produce a more intuitive API,
possibly eliminating the 'Constants' interface altogether.
MethodToProperty (193 instances):
An Objective-C method was bound as a C# property due to convention such as taking no parameters and returning a value (non-void return). Often methods like these should be bound as properties to surface a nicer API, but sometimes false-positives can occur and
the binding should actually be a method.
StronglyTypedNSArray (42 instances):
A native NSArray* was bound as NSObject[]. It might be possible to more strongly type the array in the binding based on expectations set through API documentation (e.g. comments in the header file) or by examining the array contents through testing. For example,
an NSArray* containing only NSNumber* instances can be bound as NSNumber[] instead of NSObject[].
PlatformInvoke (3256 instances):
In general P/Invoke bindings are not as correct or complete as Objective-C bindings (at least currently). You may need to fix up the library name (it defaults to '__Internal') and return/parameter types manually to conform to C calling conventionsfor the target
platform. You may find you don't even want to expose the C API in your binding, but if you do, you'll probably also want to relocate the definition to a more appropriate class and expose a stronger type-safe wrapper. For P/Invoke guidance, see http://www.mono-
project.com/docs/advanced/pinvoke/.
InferredFromMemberPrefix (29 instances):
The name of this originally anonymous declaration was taken from a common prefix of its members.
Once you have verified a Verify attribute, you should remove it from the binding source code. The presence of Verify attributes intentionally cause build failures.
For more information about the Verify attribute hints above, consult the Objective Sharpie documentation by running 'sharpie docs' or visiting the following URL:
http://xmn.io/sharpie-docs 6 warnings generated.
Done. Johns-Mac-mini:~ johnmiller$
I have solved it. There was a need to use scope when using Objective Sharpie. Simple add "-scope ~/Desktop/InfColorPicker/InfColorPicker". Then Sharpie is generating small files.
After I add a field I was able to press Ctrl + Enter and choose Initialize field from constructor. It added an argument to existing ctor or created a new ctor with that argument if it was not declared.
I wonder if this is just new version Resharper 2017.1 or old version of VS 2013?
I have it working on VS 2015 & Resharper 2016.3. But it doesn't appear when I press Ctrl + Enter in VS 2013 & Resharper 2017.1.
ReSharper 2017.1 Help states the following:
Generating Type Constructors
ReSharper | Edit | Generate Code | Constructor
Alt+Insert | Constructor
ReSharper_GenerateConstructor
The constructor generation wizard creates a non-default constructor that takes parameters for selected fields , properties and auto-properties .
All generated constructors follow the same pattern where:
Each field , property, or auto-property included in the constructor is initialized with a parameter.
The name of the parameter is derived from the name of the corresponding field or property .
If there are non-default base type constructors, the required parameters are added to the generated constructor and passed to the base class constructor.
Tip You can quickly generate constructors by typing ctor (without parameters), ctorf (with parameters that initialize all fields) or ctorp (with parameters that initialize all properties).
Tip You can set up common code generation options on the Code Editing | Members Generation page of ReSharper options.
I found another refactoring bulb (Quick actions menu Ctrl+.) (at least in new version of resharper for VS 2022) that have a menu "Add parameter to XXX.ctor"
I have a Sitecore project in which I am using visualstudio code analysis. I am using Sitecore method "Assert.ArgumentNotNull" to check for null arguments, However visualstudio code analysis engine doesn't recognize it and show "CA1062 Validate arguments of public methods" message.
Instead of creating a custom rule, Is there a easier way to tell analysis engine that "Assert.ArgumentNotNull" performs null check and message is invalid.
I don't want to suppress the message or disable it.
You can't use Sitecore's Assert class that way and that's why:
Sitecore Assert class as well as NotNullAttribute and CanBeNullAttribute were made the way ReSharper can understand when it performs its own analysis.
Definition of Assert.ArgumentNotNull(object, string) method is the following:
[AssertionMethod]
public static void ArgumentNotNull([CanBeNull] [AssertionCondition(AssertionConditionType.IS_NOT_NULL)] object argument, [CanBeNull] [InvokerParameterName] string argumentName)
All those attributes are defined in Sitecore and R# understands them because of naming conventions.
Unfortunately, VS code analysis has another naming conventions. ArgumentNotNull should look like this for you:
public static void ArgumentNotNull([ValidatedNotNull] object argument, string argumentName)
Since you can't modify the Assert class, you can't mark argument parameter with ValidatedNotNullAttribute.
I'm working on a custom Visual Studio language service, and have several questions regarding the way file extensions are bound to a particular language service.
Source files for the language "Example Language" has two primary file extensions: .e1 and .e2. My extension has a class ExampleLanguagePackage which extends Package.
When you use the File → Open command and select a C# file (for example), the "Open" button has a dropdown arrow which allows you to select "Open With...". When you click that button, you are presented with options to open the file in the "CSharp Editor (Default)", "CSharp Editor with Encoding", or any of several other options. How can I provide a similar feature for my language, offering "Example Language (Default)" and "Example Language with Encoding" options?
When you open Tools → Options... → Text Editor → File Extension, you have the ability to bind (for example) the .foo extension to "Microsoft Visual C#" or any of several other options. How can I extend this page to allow user-defined file extensions to be associated with the "Example Language"?
What else should I watch out for when registering these items?
Most of these items are addressed by adding a custom implementation of IVsEditorFactory for your language and using a combination of registration attributes to register it. The actual implementation of this interface is beyond the scope of this question, but the documentation for the interface itself (and linked to that page), along with an example DjangoEditorFactory implementation in the Python Tools for Visual Studio project helped me with my initial implementation.
To support the Example language, I will make the following assumptions.
You've implemented an abstract class ExampleEditorFactory which provides the core implementation of IVsEditorFactory. The class should have a protected constructor with a bool argument to specify whether the factory should prompt the user for an encoding (similar to one of the constructors of the DjangoEditorFactory).
You have a class ExampleEditorFactoryWithoutEncoding which extends ExampleEditorFactory and constructs the base class specifying false for the promptForEncoding argument. This class should be marked with the [Guid] attribute.
You have a class ExampleEditorFactoryWithEncoding which extends ExampleEditorFactory and constructs the base class specifying true for the promptForEncoding argument. This class should be marked with the [Guid] attribute.
You have added the following entries to your VSPackage.resx resources file. The constants can be changed, but be aware that I have used the constant values 101 and 102 below.
101 = Example Language
102 = Example Language with Encoding
Registering the editor factories
The first thing to do is register your editor factories. This is done in two parts.
First, use the ProvideEditorFactoryAttribute. This attribute associates a resource identifier for the display name of the factory with the factory type itself.
[ProvideEditorFactory(typeof(ExampleEditorFactoryWithoutEncoding), 101)]
[ProvideEditorFactory(typeof(ExampleEditorFactoryWithEncoding), 102)]
Next, in the Initialize method of ExampleLanguagePackage, add calls to RegisterEditorFactory after you call base.Initialize().
protected override void Initialize()
{
base.Initialize();
RegisterEditorFactory(new ExampleEditorFactoryWithoutEncoding(this));
RegisterEditorFactory(new ExampleEditorFactoryWithEncoding(this));
}
Associate a logical view with the editor factories
I haven't found all the information I wanted about the use cases for the ProvideEditorLogicalViewAttribute attribute, but it's important to include at least the following. Make sure to register the logical view(s) with both factories you created.
[ProvideEditorLogicalView(typeof(ExampleEditorFactoryWithoutEncoding), VSConstants.LOGVIEWID.TextView_string)]
[ProvideEditorLogicalView(typeof(ExampleEditorFactoryWithEncoding), VSConstants.LOGVIEWID.TextView_string)]
If this step is not done, the feature where double clicking in the output window can take you to a line of code will not work as expected. For example, suppose the output window contained a line like the following.
c:\dev\file.e1(14,3): unexpected expression
Associating the TextView logical view allows the IDE to use your factory when you double click on this output line to take you to line 14, column 3 of the file c:\dev\file.e1. Otherwise it will use a different factory to open a new copy of your document, and the new window will likely be missing many features.
Associate the standard file extensions .e1 and .e2 with the editor factories
This step provides the "Open With..." support for .e1 and .e2 files described in the original question 1. This step is accomplished with the ProvideEditorExtensionAttribute attribute.
The default priority for the primary factory appears to be 50. The factory with explicit encoding should have a priority less than this, and 49 appears to be a good choice. Note that there is no need to specify the NameResourceID named parameter because it was already specified by the ProvideEditorFactoryAttribute usage above (the generated registry keys are identical).
[ProvideEditorExtension(typeof(ExampleEditorFactoryWithoutEncoding), ".e1", 50)]
[ProvideEditorExtension(typeof(ExampleEditorFactoryWithoutEncoding), ".e2", 50)]
[ProvideEditorExtension(typeof(ExampleEditorFactoryWithEncoding), ".e1", 49)]
[ProvideEditorExtension(typeof(ExampleEditorFactoryWithEncoding), ".e2", 49)]
Associate the .* extension with the editor factories
This step provides the "Open With..." support for all other files, and adds support for the File Extension options described in the original question 2. This step also uses the ProvideEditorExtensionAttribute attribute, but uses a much lower priority value to ensure the default editors for other file types are not overridden by the setting. Like in the previous step, the factory with explicit encoding is given a lower priority.
[ProvideEditorExtension(typeof(ExampleEditorFactoryWithoutEncoding), ".*", 2)]
[ProvideEditorExtension(typeof(ExampleEditorFactoryWithEncoding), ".*", 1)]
Final notes
This answer does not cover several details.
(High importance for Visual Studio 2012) If you are planning to support Visual Studio 2012, please see the topic Cannot get custom editor to use the provisional tab for details on the new (and otherwise poorly documented) property ProvideEditorFactoryAttribute.CommonPhysicalViewAttributes.
(Unknown importance) The ProvideEditorFactoryAttribute does not support specifying the LinkedEditorGUID value (search down the page). This value would normally be added to the registration of ExampleEditorFactoryWithEncoding, and the value would be the GUID of ExampleEditorFactoryWithoutEncoding.
I'm throwing this out in case someone has encountered this before.
When creating DesignData for use within the WPF designer, I get one of two errors:
Object does not match target type.
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object
target)
(SNIP)
at Microsoft.Expression.DesignModel.InstanceBuilders.ClrObjectInstanceBuilder. UpdateProperty(IInstanceBuilderContext
context, ViewNode viewNode, IProperty
propertyKey, DocumentNode valueNode)
The other one is a little more informative:
The value "_.di0.MyProjectLol.MyType"
is not of type "MyProjectLol.MyType"
and cannot be used in this generic
collection.
at
System.ThrowHelper.ThrowWrongValueTypeArgumentException(Object
value, Type targetType)
(SNIP)
at Microsoft.Expression.DesignModel.InstanceBuilders.ClrObjectInstanceBuilder.
InstantiateChildren(IInstanceBuilderContext
context, ViewNode viewNode,
DocumentCompositeNode compositeNode,
Boolean isNewInstance)
When debugging, I can see that there is a dynamic assembly that is loaded with proxy-ish types that look like mine but, obviously, are not. This assembly is called Blend_RuntimeGeneratedTypeAssembly(Guid goes here). When attempting to load types in this assembly, it throws a type load exception for a number of them. So, some types get proxied, some types are left as God and I intended, and when they mix unnatural acts occur.
For example, the type "Foo" might get a proxy created, but no other types do (TypeLoadExceptions). Then the designer tries to hand one of my real types the proxy (helped by the fact that xaml serialization likes to cast collections to IList, thus shitting on type safety) and you get one of the above exceptions.
I have spent half a week trying to fix this. I've tried a hundred different things, but I can't figure out exactly what is causing it to fail. Suggestions are welcome, TIA.
Solution in two parts:
1) Ensure VS is fully updated. At this point, it means installing the Silverlight 4 tools for Visual Studio 2010. They include the latest updates to the WPF designer. If you're reading this off in the distant future, ignore this one.
2) Hit the properties for your design data files. Clear out "Custom Tool", and set the "Build Action" to either "DesignData" or "DesignTimeDataWithDesignTimeCreatableTypes".
DesignData means that your types cannot be deserialized from xaml directly (due to dependencies or the such), so the designer attempts to create mocks for those types and presents the mocks to your design surface.
DesignTimeDataWithDesignTimeCreatableTypes means that the designer will load your assemblies and deserialize the xaml directly into your types without creating mocks.
This can also be caused by a certain combination of situations that, when combined, cause deserialization to fail.
Essentially if you have
A custom collection, or a collection that doesn't implement IList
That is exposed as a property on your type
Which is defined in a different assembly
you can get this error message as well.
It is very important that your collection property types implement IList (the non-generic one) if you want to serialize them to and from xaml!