I have cases where the "uses" doesn't seem to work

I generated a Silverlight service interface file using SLSvcUtil. Here is part of what got generated:

namespace ;

interface

uses
    System.Runtime.Serialization;
    
type
    [System.CodeDom.Compiler.GeneratedCodeAttribute('System.ServiceModel', '4.0.0.0')]
    [System.ServiceModel.ServiceContractAttribute(&Namespace := 'http://www.swtechnologies.com/edb', ConfigurationName := 'IEDBService')]
    IEDBService = public interface
    [System.ServiceModel.OperationContractAttribute(AsyncPattern := true, Action := 'http://www.swtechnologies.com/edb/IEDBService/GetEDBUserSecurity', ReplyAction := 'http://www.swtechnologies.com/edb/IEDBService/GetEDBUserSecurityResponse')]
    method BeginGetEDBUserSecurity(DataConnectionKey: System.String; callback: System.AsyncCallback; asyncState: System.Object): System.IAsyncResult;
    method EndGetEDBUserSecurity(&result: System.IAsyncResult): Service.DataContracts.UserSecurity;

I add that file to my project. Then I add a “uses Service,Service.DataContracts” at the top of another source file in the same project.

The compiler says unknown namespace for both Service and Service.DataContracts.

Shouldn’t I be able to reference the UserSecurity and ALL the other myriad classes in that generated code without having to prefix every single one of them with the namespace?

Seems like I had this issue come up in the past. I’m not sure if I posted about it, but I couldn’t find one, so maybe I didn’t.

Not sure if I get it.This generated file has no namespace & fully qualified type names.

Other files that use this file can do

uses Service.DataContracts;

and then call this function withotu fully qualifying the type names. Presuming the assembly that defines them is in the references of course.

No, my point is that other files CAN’T do “uses Service.DataContracts”. THAT is the problem I’m trying to solve. I had to prefix a bunch of datacontract object classes.

I think the slSvcUtil generated file NEVER has its own namespace, that I’ve seen anyway.

here is what was on the command line:

slSvcUtil http://localhost/EDBWebsite/Service.svc?wsdl /language:Oxygene /directory:"C:\Users\Mark\Documents\Visual Studio 2013\Projects\SW\OPG\EDB\EDBSilverlight\EDBSilverlight"

Here is the start of the service file:

namespace Service;

interface

   uses
      System,
      System.Data,
      System.Runtime.Serialization,
      System.Collections.Generic,
      System.ServiceModel,
      System.ServiceModel.Activation,
      Service.DataContracts,
      EDB.EDBDatabase;

   // having it all to do over again, I would make the getoptions and setoptions work on a single object that is 
   // all defined here and passed to the database for filling in or using for updating
   type
      [ServiceContract( &Namespace := "http://www.swtechnologies.com/edb" )]
      IEDBService = public interface

Now Oracle has managed to screw me up and I can’t even publish any more… But that is another story…

If you can send us a sample of how to reproduce this I can take a look.

SilverlightApplication133.zip (136.0 KB)

Here is a little skeleton that just includes the bad generated file in the project. Look at Page.xaml.pas for the example lines.

I just added Service to the namespace in the generated file, and the page.xaml.pas compiled ok. Now maybe need to figure out why the generated file doesn’t have that namespace in it.

Thanks, logged as bugs://74528

I see what you mean. It’s like it somehow doesn’t “register” Service.DataContracts as a valid namespace.

bugs://74528 got closed with status fixed.

Great! Thanks. This one has bothered me from time to time.

Yeah it’s a bit of an edge case, I don’t often see files with an empty namespace.

It is what is generated by default by slSvcUtil which is passed the Oxygene language. Don’t know if they are dropping the ball on that or Oxygene or whether I should have specified something somewhere to make it output the namespace.

Often there are also extra repeated lines generated in the output uses statement.

Things like:

uses
     namespace1,
     namespace1,
     namespace1;

I don’t have an example at the moment, but I’ve seen that. It never caused a compiler problem.

And if I put the namespace name in there after it is generated, then it just gets wiped out the next time it is generated.