|
Wiep Corbier wrote: My solution is already super fast. So don't worry about the expense of searching an 80 item list. Even though a straight search in a simple string is super fast, it does not imply that other alternatives are unacceptably slow.
|
|
|
|
|
I agree
Everywhere else I use a different approach like list, dictonary etc
I use ms sql server databases. I love creating related tables. It's what I do all the time.
But this time only I took a different path. (
|
|
|
|
|
Dave Kreskowiak wrote: It's not the language that needs to updated to support your poor skills. It's your skills that need to be updated to better support your customers.
Hear hear! :applause:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wiep Corbier wrote: All these problems are already solved by me. Errr, no you haven't. You have talked about one narrow point and extrapolated that to having answered my whole question.
I'll put this to you another way. Describe EXACTLY how this mechanism would work. How would it work with vars? How would it run through a CI pipeline? How will it cope with type explosions and types with differing numbers of fields? I want this class to be COM Compatible, how's that going to work? I want to use IoC to inject one of these classes, which one would it pick? In other words, explain how you plan to cope with ALL of the edge cases that would be introduced.
|
|
|
|
|
Wiep Corbier wrote: what if my customers could make a choise how to recieve the data using the same name for the claas but had the option how it was presented/formatted. So why don't you provide that in the one class you've got? dotNet doesn't know how to ask the customer - their language, preferred terminology, CLI or GUI, how your GUI is laid out and how the selection list should be presented. You do. You are the only one who can ask the customer in a proper way, and from the selected alternative initialized the object this way or that way. Or if you insist, create an object of this or that class.
Two accessor methods of a given class may very well reference the same private data, presenting it in different formats (or set functions parsing value in different ways before storing it in the private value). You would have an explicitly declared internal value, not implicitly declared ones, so the simple {get; set;} would be relpaced with e.g. for the list format:
{ get { return skills.Split('|'); }
set { skills = string.Join("|", value); }} In this case, "skills" may actually be the implicitly declared variable from your string based accessor. Your (single) class may have as many different accessors (here: presentation formats) as you like. Of course you may have have initializers as well accepting intial values in either format, but being parsed and stored in one common format.
If you are using this "skills" case as a simple way of illustrating what you think should be a commonly available mechanism for a lot of different purposes, then you should come up with a better illustration of the need.
If your real problem is accessing the list of skills as a list or as a string, then it is handled by two properties (accessors) presenting the skills in two different ways from the one class.
If you insist on two different classes with a single name, they will be different (you asked for it, you got it) - different set of members, different methods, different semantics. In the general case, only the name would be the same. You may construct examples where two different classes happen to have some members with similar names and somewhat similar semantics, while others differ. The overlap is more or less "accidental"; a general mechanism could not require "> x% similarity between same-name classes", it would be general (sic!). We have a general object class - it is called "object". Your proposal is, in the generalized sense, more or less to make an "object2" class: If the class name implies nothing about object members or semantics, it has no syntactic or semantic value. You have no clue about what to expect from an object of that name.
I am fully satisified with the classic "object" class. I don't see a need for an "object2" class.
|
|
|
|
|
I have read you contribution. Thanks for that.
What I want doesn't exist and I'm not interested in alternatives that already exists.
I want something new.
I want the team that creates C# to make that happen.
All of you think I have a dumb idea.
But for me, inheritances is dumb. Interfaces are dumb, and many more
Why? You don't need them. There are other ways to do the same.
But they exist because someone had the idea and others liked it.
The difference is, they understand it. Nobody understands my idea. Doesn't matter, I'm used to it.
ps: I don't want a class with two representation of the skill data. I just do not want that.
(of course it's an idea that crossed my mind)
|
|
|
|
|
Wiep Corbier wrote: ps: I don't want a class with two representation of the skill data. I just do not want that. But I suggest a single reperesentation! Two representations would be really bad design. Two different presentations is a completely different thing.
It is like when your code handles a binary integer, you don't present it like a binary integer but format it into a character string. You may format it as hex, octal, decimal, with or without leading zeroes, trailing currency sign or whatever. For binary reals you print out the number of decimal positions according to need. The internal integer or real binary value is unique and unaffected by the presentation format.
Similar with you skills list. Whether it is stored as a single string with | separators, a list, a dictionary or as a database table doesn't matter: From that unique representation you may format it as a string, as a list or in any other format. For console output, you use different Format or ToString format strings, for binary formats, you use different accessors (that may also use Format/ToString when appropriate).
An accessor isn't a representation. It is an accessor, a way to get at a representation. The representation is independent of it.
|
|
|
|
|
Perhaps I misunderstand something ... but when I read your question I want to ask why you don't create a Property (as a List of String or as List of Class-Object) which could be used in the way you want : either you use only a part of the Property (in case of List of String) or you use a sub-Property (in case of List of Class-Object).
|
|
|
|
|
Wiep Corbier wrote: What I want doesn't exist and I'm not interested in alternatives that already exists.
I want something new.
Good luck with that Sparky... I've been coding for over 40 years, and have NEVER come up with a use case for identical class names (I'd really like to see multiple inheritance come back, though).
Your actual problem is your weak design, not a perceived missing feature in C#.
Fix your code.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Wiep Corbier wrote: As you can see, the property with the name Skills is a string.
It can be a long string and it stores one or more Skills. Forget multiple classes with the same name, I'm wondering why in the world you would do this.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Why? I just explained it several times.
Quote: When answering a question please;
Read the question carefully
|
|
|
|
|
Wiep Corbier wrote: I just explained it several times. Not in your OP.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Wiep Corbier wrote: For the next C# version I would like the ability to have multiple classes with the same name. You'd have to contact Microsoft.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Whose "popup"?
You'll need a separate NAMESPACE for each DUPLICATE CLASS NAME.
Then you can "code logic" for YOUR "popup" or whatever.
And in your CODE, you qualify with a NAMESPACE that VS can resolve with (Intellisense-wise).
There is no other magic; it's all in the head.
YOU are the only "customer" at this stage.
Beyond that, you use "Interfaces".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
modified 16-Jun-20 13:13pm.
|
|
|
|
|
Wiep Corbier wrote: So, when I instantiate a new CandidateFunction, I want a popup asking me which one I want to use.
Making 2 classes indistinguishable is a bad idea to the core.
In 35 years, I never came to a case that need such Gremlin.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Well that was an interesting discussion which seems to have shown that you need to redesign your data structure to meet your requirements. The entire issue revolves around the string of skills which you are storing incorrectly (as a number of respondents have pointed out).
This should be seen as a valuable lesson (hopefully others will also benefit). Do not be discouraged by any negative responses, this was a good discussion with some interesting information generated.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
For me personally, I would say that you should be trying to solve a modelling issue rather than fix it with a "change to the complier"
Which I wouldn't agree to it, if I worked for Microsoft
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
You can't have multiple classes with the same name, unless they're in different name spaces.
This won't work:
namespace One
{
public class ABC {}
public class ABC {}
}
but this will (as long as you fully qualify all instantiations):
namespace One
{
public class ABC {}
}
namespace Two
{
public class ABC {}
}
You could use inheritance, but your class names would still have to be unique.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I'm sorry I've missed this answer and discovered it only when posted mine with the similar thinking
|
|
|
|
|
Pardon me if this was already mentioned, this is a fairly long thread. But I have a feeling that this case is handled by namespaces for a couple of decades. I mean you can have a POCO for your needs in one namespace and another class for what customers want in the other namespace. And you can map one to another manually or via some tool like Automapper.
Quote: I want a popup asking me which one I want to use.
Also, I have a feeling that you're confusing language and tooling. Is popup some sort of language construct or a feature in IDE? Which one? VS? VS code? Jetbrains rider?
|
|
|
|
|
Hi,
Not sure which forum I need to use for this issue. Currently we are using visual studio 2012 ,Community edition ,net framework 4.0. On our workstations, we installed Visual Studio Enterprise 2019 version. We Should migrate our project to.net framework 4.7.2 in VS2019. When I open project in VS 2019 with .net framework 4.7.2, it is giving the run time error as Authentication error (Project was successfully build without any error). Where the same project worked good on VS2012.
It is showing
"
Exception Details: System.UnauthorizedAccessException: Windows Integrated Security is not enabled
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true">, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 115: {
Line 116:
Line 117: throw new UnauthorizedAccessException("Windows Integrated Security is not enabled");
Line 118: }
Line 119:
"
Where i have enabled windows integrated security .
windows authentication as enables and anonymous authentication as disabled.
Can anyone please help me what changes i need to make over here?
modified 15-Jun-20 6:39am.
|
|
|
|
|
That's an error being thrown by your code, not the framework. Look at the preceeding lines in that method to see why you're reaching that exception.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
When the same code was executed in VS2012 it worked without any error and authentication was true
"void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (Context.Request.IsAuthenticated)
{
Context.User = UserPrincipal.Authenticate(Context.User.Identity as
System.Security.Principal.WindowsIdentity);
Thread.CurrentThread.Name = UserPrincipal.CurrentUser.LoginName;
}
else
{
throw new UnauthorizedAccessException("Windows Integrated Security is not enabled");
}
}
"
The above method is where i'm facing issue. In VS2019 the IsAuthenticated is returning false where it returned true in VS2012 and worked fine.
|
|
|
|
|
Then you either haven't enabled Windows Authentication, or you haven't disabled Anonymous Authentication.
Check your settings in web.config - you should have both:
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
</system.web> and:
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" />
<basicAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer> NB: You may need to "unlock" the authentication section to be able to configure it. In IIS Manager, it's under "Feature Delegation". If you're using IIS Express, you'll need to edit the applicationhost.config file in the .vs\config hidden folder.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I checked with this code with empty web Form to check if authentication is working .
I received this error ,even after configuring the applicationHost.config (handler = Allow).Could you please help with this
Error:
"HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module WindowsAuthenticationModule
Notification AuthenticateRequest
Handler PageHandlerFactory-Integrated-4.0
Error Code 0x80070021
Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Config File \\?\C:\Users\rharishpr\source\repos\WebApplication3\web.config
Requested URL https://localhost:44386/WebForm1.aspx
Physical Path C:\Users\rharishpr\source\repos\WebApplication3\WebForm1.aspx
Logon Method Not yet determined
Logon User Not yet determined
Config Source:
18: <authentication>
19: <windowsauthentication enabled="true">
20: <basicauthentication enabled="true">
"
Method used to check Windows authentication part:
" protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Application code executed using ");
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name + " ");
Response.Write("Is User Authenticated: ");
Response.Write(User.Identity.IsAuthenticated.ToString() + " ");
Response.Write("Authentication Type, if Authenticated: ");
Response.Write(User.Identity.AuthenticationType + " ");
Response.Write("User Name, if Authenticated: ");
Response.Write(User.Identity.Name + " ");
}
"
Web.config:
"
<configuration>
<system.web>
<compilation debug="true" targetframework="4.7.2">
<httpruntime targetframework="4.7.2">
<authentication mode="Windows">
<authorization>
<deny users="?">
<system.webserver>
<security>
<authentication>
<windowsauthentication enabled="true">
<basicauthentication enabled="true">
<anonymousauthentication enabled="false">
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warninglevel="4" compileroptions="/langversion:default /nowarn:1659;1699;1701">
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warninglevel="4" compileroptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+">
"
modified 16-Jun-20 3:33am.
|
|
|
|