Error when adding scoped dependency and different 'arity' - .net-core

I'm attempting to register the following:
services.AddScoped(typeof(IReadRepository<>), typeof(EfRepository<,>));
However I'm receiving this error message:
Error: Arity of open generic service type 'Harmony.Data.Common.Abstractions.IReadRepository1[T]' does not equal arity of open generic implementation type 'Harmony.Data.SqlServer.EfRepository2[T,TContext]'. (Parameter 'descriptors')
For the resolved to type, the first type param is to be passed as the type argument to IReadRepository. The second param is of type DbContext which has already been registered.
Is there some other trick I'm missing here?
Thank you!

Related

Compiler Error Message: CS1061: does not contain a definition (Missing Reference)

object does not contain a definition for Database and no extension method Database accepting a first argument of type object could be found (are you missing a using directive or an assembly reference?)
UserStore userStore = new UserStore();
userStore.Context.Database.Connection = System.Configuration.ConfigurationManager.
ConnectionStrings["CartDBConnectionString"].ConnectionString;
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
Based on the image you supplied you are missing a reference to the following library:
Microsoft.AspNet.Identity.EntityFramework
You can often figure out which Library you are missing by looking up (in MSDN) the object that is giving you the error. In your case (according to your image) the object was IdentityUser . If you do a look up:
IdentityUser
It will point you to the missing assembly I indicated above.
You (first) need to create a reference to this library for you project:
Adding Reference
then add it to your code with the Using Keyword:
using directive
or
Using KeyWord
The error message you posted:
'object' does not contain a definition for 'Database' and no extension
method 'Database' accepting a first argument of type 'object' could be
found (are you missing a using directive or an assembly reference?)
is a little ambiguous and implies another bad/missing reference but I would need to see the code that is triggering that message.

Invoke Method in WorkFlow expecting Optional Parameters to be passed?

I have method in Business Layer, which contains some optional parameters.
When I am trying to invoke the method from the WorkFlow 4.0, it is expecting me to pass
the optional parameters also.
Is there a way that I can avoid passing optional parameters to the method.
The method that I have is SendEmail(string emailTo, string domain, string smtpAdress = "POP");
When I call this method any where in the code.. I am just calling the method like
SendEmail("xx.com","PFE"), which is working fine
But in the Workflow..it gives a compilation error saying that
" 'BLEmail' does not have a public instance method named 'SendEmail' matching the parameter types, generic type arguments, and generic type constraints supplied to InvokeMethod 'InvokeMethod'."
When I am passing the optional parameter, it works fine..but it loses the whole concept of optional parameter.
Please help..
Thanks and appreciate your feedback.
Sam.
InvokeMethodActivity does not handle optional parameters. You have to provide all parameters regardless if they are optional or not.

Dynamic object arguments in WF4 Activity

Is it possible to use dynamic objects (extending DynamicObject) in WF4 Activity that can be used in expressions?
I get the following error messages when running a unit test that invokes an activity that had a dynamic object as a parameter.
using DynamicObject as the argument type
System.Activities.InvalidWorkflowException : The following errors were
encountered while processing the workflow tree:
'Literal': Literal only supports value types and the
immutable type System.String. The type System.Dynamic.DynamicObject
cannot be used as a literal. 'Legal': The private implementation of
activity '1: Legal' has the following validation error: Compiler
error(s) encountered processing expression "deal.Region = "EMEA"".
'Region' is not a member of 'System.Dynamic.DynamicObject'.
Using actual type as argument type
System.Activities.InvalidWorkflowException : The following errors were
encountered while processing the workflow tree:
'Literal': Literal only supports value types and the
immutable type System.String. The type
WorkflowTest.DealValueHelper cannot be used as a literal.
'Legal': The private implementation of activity '1: Legal' has the
following validation error: Compiler error(s) encountered processing
expression "deal.Region = "EMEA"". 'Region' is not a member of
'WorkflowTest.DealValueHelper'.
Yes, this absolutely works. I've created just such an object in Microsoft.Activities.Extensions.WorkflowArguments.
What you are encountering is likely an error when trying to assign directly to an InArgument of an activity. I wrote a blog post about this Passing arguments to Workflow Activities (again)

RegisterType with Unity

I'm having trouble resolving an type with unity. I have a service that takes a Uri and bool.
Foo(Uri uri, bool bar)
When I try and resolve Foo Unity complains
The type Uri has multiple constructors of length 2. Unable to disambiguate
I tried to RegisterInstance but to no avail.
What am I missing?
If your class has more than one constructor that takes two arguments you would have to specify which one Unity should use.
If your constructor takes primitive arguments like strings, bools or URIs you would either have to register your mapping with these arguments or provide them at resolve time.
container.RegisterType<Foo>(new InjectionConstructor(new Uri("http://bla.com"), false));
or
Foo foo = container.Resolve<Foo>(new ParameterOverride("uri", new Uri("...")), new ParameterOverride("bar", false)));
should work. Although I would not recommend the second approach. A DI container should not be used in that manner.
I had the same error message when initialising a wcf client by Unity. As i'm setting Unity in my config, the solution is
<register xxx>
<constructor></constructor>
</register>
to explicity invoke the constructor without parameter.

ActionScript: Type coercion problem with BlazeDS/AMF and class interfaces

I've got a problem with type coercion in a Java/Hibernate/BlazeDS/Flex-Setup.
First of all, my classes look like this:
--- JAVA ---
Interface I
(Abstract) Class A implements I
Class B extends A
--- ActionScript ---
Interface I
Class A implements I
Class B extends A
I got RemoteClass-Meta-Tags in all ActionScript-Classes/Interfaces I, A and B. Package structure and Class/Interface names are exactly the same.
Now here's the problem:
My Java Service successfully retrieves objects of class B from my database via Hibernate. I got another class C which has a member property of interface type I, so it should be possible to assign an object of type B. But for some reason i get the following error message:
TypeError: Error #1034: cannot convert Object#28b44a89 to package.name.I
I checked the Java object type in the service and it is of type B and seems to be totally fine. Why can't the object of type B be assigned to a member variable of type I? This is driving me nuts.
Thanks in advance.
Check the type the objects returned by the service call (inspect the result with a debugger in Flash Builder). Maybe they are not properly converted to type B and an ObjectProxy is created. If it's not the case, please post your code.
I got same strange issue.
My situation like this:
I develop an web application with Flex 4 + Spring
In Java, I have class Message.
In Flex, I have class Message.
When getting remote java object from server and cast to Message type in Flex, this error will occur. The strange thing is that, on the first time, it's OK to cast to Message type in Flex from remote java object and there's no error; but in the second time, it fail and error will be shown.
To solve this, I have one solution: using registerClassAlias() method to register for remote java class.
But I wonder if there's other solution for this issue. Is this a bug of Flex?

Resources