Having error CS0234: The type or namespace doesn't exist when doing partial make mono class library

StackOverflow https://stackoverflow.com/questions/23591665

  •  20-07-2023
  •  | 
  •  

Pergunta

I was trying to add some missing class into the mono class library package. My class make use of other assembly. I have put that assembly reference into .csproj file, but it does not help.

What should I do in order to use the class from other assembly? It seems to me the .csproj file does not get compiled when I do "make".

I have taking some time on Mono Project Contribution page (http://mono-project.com/Contributing) but I still cannot find how to do it.

Here is my code:

using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Security;
using System.Linq;
using System.Text.RegularExpressions;

namespace System.Web.Security
{
    [AttributeUsage(
        AttributeTargets.Property | AttributeTargets.Field | 
        AttributeTargets.Parameter, AllowMultiple = false)]
    public class MembershipPasswordAttribute : ValidationAttribute
    {
...

I try to use System.ComponentModel.DataAnnotations which is under /mono/mcs/class/System.ComponentModel.DataAnnotations. My class is under System.Web assembly (/mono/mcs/class/System.Web/System.Web.Security).

Here is a part that I do reference in .csproj file

  <ItemGroup>
...
    <ProjectReference Include="..\System.ComponentModel.DataAnnotations\System.ComponentModel.DataAnnotations-net_4_5.csproj">
      <Project>{64e625c0-aa4e-44dc-98f4-352d552f2ef8}</Project>
      <Name>System.ComponentModel.DataAnnotations\System.ComponentModel.DataAnnotations-net_4_5</Name>
    </ProjectReference>
  </ItemGroup>

Thank you in advance!

Foi útil?

Solução

the .csproj file isn't what you're looking for. I'm actually working on this exact same class (which is a great coincidence).

mono doesn't use .csproj files.... I mean.... it does, but not really. Those are more for users who prefer developing using an IDE like visual studio/xamarin etc. in the /mcs/class/System.Web directory open Makefile and add this to line 258 -r:System.ComponentModel.DataAnnotations \ That is what appears to have worked for me.

Now run make again and you should no longer get the compilation error.

Don't forget to add System.Web.Security/MembershipPasswordAttribute.cs to line 4 of net_4_5_System.Web.dll.sources in the same directory.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top