c# - Code sample not compiling -


i have been trying use sample code provided microsoft.

  1. downloaded file
  2. hit unblock on file
  3. unzipped file
  4. clicked on solution called quizgame sample
  5. the solution opened in visual studio 2015
  6. the solution automatically registered hundreds of errors
  7. i opened c# files in solution explorer see going on , each c# file had tons of errors. each error how related system reference.

error cs0246 type or namespace name 'system' not found (are missing using directive or assembly reference?)

the warning was

warning cannot resolve assembly or windows metadata file 'system.runtime.dll'

it shows system imports red lines underneath them. sounds not recognizing system reference.

here code

using system; using system.collections.generic; using system.linq; using system.text; using system.threading; using system.threading.tasks; using system.runtime.interopservices.windowsruntime; using windows.networking.sockets;  namespace p2phelper {     public class p2psessionhost : p2psession, idisposable     {          private dictionary<guid, p2pclient> clientmap { get; set; }          private streamsocketlistener sessionlistener { get; set; }          private timer timer { get; set; }      public p2psessionhost(p2psessionconfigurationdata config) : base(config)     {         this.sessionlistener = new streamsocketlistener();         this.clientmap = new dictionary<guid, p2pclient>();     }      public void dispose()     {         this.sessionlistener.dispose();         this.sessionlistener = null;     }      public async task<bool> createp2psession(sessiontype type)     {         if (this.sessionlistener == null) return false;         if (type != sessiontype.localnetwork) throw new notsupportedexception(             "sessiontype.localnetwork sessiontype supported.");          this.sessionhost = true;         this.sessionlistener.connectionreceived += async (s, e) => await onconnectionreceived(e.socket);           await this.sessionlistener.bindendpointasync(null, settings.tcpport);         this.initializenetworkinfo();         return await this.initializemulticast(null);     }      public bool removeclient(guid clientid)     {         return this.clientmap.remove(clientid);     }      private bool acceptingconnections { get; set; }     public void startacceptingconnections()     {         acceptingconnections = true;         this.timer = new timer(async state => await sendmulticastmessage(""), null, 0, 500);        }      public void stopacceptingconnections()     {         acceptingconnections = false;         this.timer.dispose();     }      private async task onconnectionreceived(streamsocket socket)     {         byte[] message = await retrievemessage(socket);         var newclient = new p2pclient { clienttcpip = socket.information.remoteaddress.tostring() };         if (acceptingconnections)         {              if (getguid(newclient).tostring() == (new guid()).tostring())             {                 guid newguid = guid.newguid();                 this.clientmap.add(newguid, newclient);                 this.onconnectioncomplete(newguid);             }         }         this.onmessagereceived(message, getguid(newclient));     }      private guid getguid(p2pclient client)     {         return this.clientmap.firstordefault(             kvp => kvp.value.clienttcpip == client.clienttcpip).key;     }      protected async task sendmulticastmessage(string output)     {         using (var multicastoutput = await this.multicastsocket.getoutputstreamasync(             new windows.networking.hostname(settings.multicastip),              this.multicastsocket.information.localport))         {             await multicastoutput.writeasync(encoding.utf8.getbytes(output).asbuffer());         }     }      public async task<bool> sendmessage(guid clientid, object message, type type = null)     {         p2pclient client;         if (this.clientmap.trygetvalue(clientid, out client))         {             return await base.sendmessage(message, client.clienttcpip, settings.tcpport, type ?? typeof(object));         }         return false;     }      public async task<bool> sendmessagetoall(object message, type type = null)     {         var messagetasks = this.clientmap.keys.select(guid => this.sendmessage(guid, message, type));          // when tasks complete, return true if succeeded.          return (await task.whenall(messagetasks)).all(value => { return value; });     }   } } 

not recognizing .net references , namespaces system.generics, system, etc, usualy caused compiling in client profile or referencing dlls compiled using different versions of .net. go project settings , validate compiling right version of .net no client profile turned on.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -