I am currently working on a project with SignalR. On my production server, it is missing an automatically generated js-file in ~/signalr/hubs.
I wanted to try this solution:
SignalR not working on production server
But when I try to add this line to my application_start method in global.asax, my project will not build anymore. Although intellisense knows and suggests the extension method!
I referenced the namespace with using SignalR;. I tried calling it as an extension method and calling it as a static method with the object instance as the first parameter.
The exact error messages:
When calling as extension method:
Error 1 'System.Web.Routing.RouteCollection' does not contain a definition for 'MapHubs' and no extension method 'MapHubs' accepting a first argument of type 'System.Web.Routing.RouteCollection' could be found (are you missing a using directive or an assembly reference?)
When calling as static method:
Error 1 The type or namespace name 'RouteExtensions' does not exist in the namespace 'SignalR' (are you missing an assembly reference?)
Anybody knows why this happens and how to solve the problem? Many thanks in advance!
I'm pretty sure that it could be one of these reasons:
Your project requires a reference to an assembly that's not added to the project.
Is your project using the .NET Framework version that's compatible with the referenced assembly?
With your given info, it would be hard to determine the exact reason, but I believe that I provided you some helpful hints.
The fact that intellisense suggests you anything like an extension method won't mean that the project has the required references to work properly.
Related
I am attempting to persist Keys to SQL using the PersistKeysToDbContext extension from services.AddDataProtection(). At the moment we are using PersistKeysToStackExchangeRedis which works really well, however a need was identitied to move it to DB instead.
We are using a .net Core 2.2 project having added the following references:
Microsoft.AspNetCore.DataProtection.EntityFrameworkCore (2.2.0)
Microsoft.AspNetCore.DataProtection.Extensions (2.2.0)
Microsoft.AspNetCore.DataProtection.StackExchangeRedis (2.2.0) (obviously for current functionality)
Microsoft.EntityFrameworkCore (2.2.0)
services.AddDataProtection().PersistKeysToDbContext<ApplicationDbContext>();
I get the following error from the compiler:
'IDataProtectionBuilder' does not contain a definition for 'PersistKeysToDbContext' and no accessible extension method 'PersistKeysToDbContext' accepting a first argument of type 'IDataProtectionBuilder' could be found (are you missing a using directive or an assembly reference?)
1) Make sure you have Microsoft.AspNetCore.DataProtection.Extensions + Microsoft.AspNetCore.DataProtection.EntityFrameworkCore installed (as references).
2) Add using Microsoft.AspNetCore.DataProtection; to Startup.cs (or wherever you have the problem).
I've tested and it works, so if it still doesn't work, you probably need to make sure you haven't missed anything.
I am having the following error when adding any custom field or overriding any attribute on existing fields on Marketing Campaign screen:
\App_RuntimeCode\PX_Objects_CR_CRCampaign_extensions.cs(1): error CS0246: The type or namespace name 'AP' could not be found (are you missing a using directive or an assembly reference?)
Any idea on where to track this error?
This likely occurred because of using static directive or nested namespace.
For example, having AP.xyz nested in PX.Objects.AP produces no compiler error:
When AP.xyz is nested in another namespace it's not found:
The issue with using static directive is a bit different but results in the same error. This can occur because runtime code uses IIS for compilation and IIS compiler is not the latest dot net compiler. So using static directive can work when you compile a dynamic library extension in visual studio but can fail when it's compiled by IIS as part of a runtime customization.
The easy fix is to edit the files to either:
Fully qualify the identifiers by changing AP.xyz to PX.Objects.AP.xyz
Sometimes all that is required is to remove AP. and add using PX.Objects.AP at the top of the file if it's not there. When there's a conflict between 2 types with the same name in different namespace you must use method #1.
I'm creating an Windows Application for the database backup and I've already added the references in my projects.
But I got the error:
'System.Data.SqlClient.SqlError' does not contain a definition for
'Message' and no extension method 'Message' accepting a first argument
of type 'System.Data.SqlClient.SqlError' could be found (are you
missing a using directive or an assembly reference?)
I've already attached the screen shot of the error. Please help me with this issue. Thanks.
As stated in two of the errors, you are missing an assembly reference to System.Data. Add this at the top of your code file (outside of any class or method) as using System.Data; and that should resolve the problem.
Or, right click on the underlined code and use the context menu to automatically add the missing reference.
<div class="dateAdded">Article submitted #article.DateAdded.ToRelativeDateStringUtc()</div>
Compiler Error Message: CS1061: 'System.DateTime' does not contain a definition for 'ToRelativeDateStringUtc' and no extension method 'ToRelativeDateStringUtc' accepting a first argument of type 'System.DateTime' could be found (are you missing a using directive or an assembly reference?)
Here is where my error is occurring. I have a class that contains ToRelativeDateStringUtc() included in my program. Is this a MS class that I have to import? I do not see it listed anywhere in the .net reference list. I'm sure its something simple, does anyone have any ideas?
I have already added the folder to my webconfig that includes the class, which contains the method the program is "missing". So its not missing it... I just dont know what else to do from here.
There are several things you could try.
Firstly, you can try the using directive inside the view you use this in:
#using Your.Namespace.Where.Extension.Class.Is.Located
Secondly, the web.config you've added the namespace to is probably the global one. If this view is inside an Area.. try putting the namespace into the web.config that is inside that particular area.
The first one will work regardless.
Heys all, I've tried to use NRefactory(Vb) https://github.com/icsharpcode/NRefactory/ but it didn't come with mono.cecil.dll so i downloaded that too, but when i merged it together the versions seem
to be off (i had error Mono.Collections missing class)
does anyone seem to be able to get NRefactory working?
Edit:
btw i've changed to Mono.Cecil 0.9.4. However when i try to build ICSharpCode.NRefactory i had some errors:
Error 6 'Mono.Cecil.PInvokeInfo' does not contain a definition for
'IsBestFitDisabled' and no extension
method 'IsBestFitDisabled' accepting a
first argument of type
'Mono.Cecil.PInvokeInfo' could be
found (are you missing a using
directive or an assembly
reference?) C:\Users\Joseph\Desktop\Test\NRefactory\ICSharpCode.NRefactory\TypeSystem\CecilLoader.cs 376 14 ICSharpCode.NRefactory
post)
In the new Version the Method IsBestFitDisabled now is called: IsBestFistDisabled
The got an extra "s" inside... :)
Did you make sure to get Mono.Cecil 0.9.4 as mentioned on the GitHub page?
It has a different API than the previous Mono.Cecil 0.6.9.