Ошибка в WPF С# Ссылка на объект не указывает на экземпляр объекта.”

Всем привет, начинаю писать приложения на WPF. Возникла, мне кажется детская проблема, но не могу исправить.

System.NullReferenceException: “Ссылка на объект не указывает на экземпляр объекта.”

ChangelogText было null.

XAML код

<UserControl x:Class="AndroidRomTool.Views.Control.AboutControl"          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"           xmlns:local="clr-namespace:AndroidRomTool.Views"          mc:Ignorable="d"           d:DesignHeight="548" d:DesignWidth="1010" > <Grid Background="#EFEFF1">         <FlowDocument>             <Paragraph>                 <Run Text="Beta Version"/>             </Paragraph>         </FlowDocument>     </RichTextBox>  </Grid> 

С# Код

using System; using System.IO; using System.Reflection; using System.Windows; using System.Windows.Controls; using System.Windows.Documents;  namespace AndroidRomTool.Views.Control {        /// <summary>       /// Логика взаимодействия для AboutControl.xaml        /// </summary>        public partial class AboutControl : UserControl       {      public AboutControl()     {         LoadChangelog();          InitializeComponent();      }     public void LoadChangelog()     {         string fileName = "text.txt";          TextRange range;          FileStream fStream;          if (File.Exists(fileName))          {              range = new TextRange(ChangelogText.Document.ContentStart, ChangelogText.Document.ContentEnd);              fStream = new FileStream(fileName, FileMode.OpenOrCreate);              range.Load(fStream, DataFormats.Text);              fStream.Close();          }     } } 

}

Можете помочь.

How could I apply enums to this block of code that checks against user input and returns a response based on that input?

How could I use enums in the following block of code to simplify it? The block is a program that has a command interpreter that returns different data based on user input. Is there a way I could easily apply enums and a match statement to the logic here?

use std::io;  fn main() {     let version = String::from("0.0.1");     let mut input = String::new();      shell(&mut input, &version); }  fn shell(input: &mut String, version: &String) {     input.clear();     match io::stdin().read_line(input) {         Ok(b) => {             if &input.trim() == &"ver" || &input.trim() == &"what are you" {                 println!("C ute R ust A mateur B eginner Shell ver: {}", version);                 shell(input, version);             } else {                 println!("Command '{}' Not Recognized", input);                 shell(input, &version);             }         }         Err(err) => panic!("incorrect"),     } } 

Como resolver este problema com form?

Olá, não sou programador, mas estou precisando criar um formulário onde possa criar uma ficha de inscrição, que automaticamente irá enviar um email de confirmação para o “inscrito” e também irá gerar um arquivo no servidor em pdf, que será o crachá do indivíduo, para ser impresso e entregue em loco.

Estou tendo problemas para juntar este código de upload de foto com o script do formulário, me ajudem por favor

index.php

<!DOCTYPE html> <html>  <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <meta http-equiv="X-UA-Compatible" content="ie=edge">     <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'>     <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css'>     <link rel='stylesheet prefetch' href='http://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.0/css/bootstrapValidator.min.css'>     <link rel="stylesheet" href="css/style.css">     <title>I EVA Chapada Diamantina</title> </head>  <body>     <div class="container">         <form class="form-horizontal" action="inscrito/gerador.php" method="post" id="contact_form">             <fieldset>                 <center>                     <h1>Inscrição</h1>                     <h2>I EVA - Chapada Diamantina</h2>                 </center>                 <p>&nbsp;</p>                 <div class="form-group">                     <label class="col-md-4 control-label"></label>                     <div class="col-md-4 inputGroupContainer">                         <div class="input-group">                             <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>                             <input name="apelido" placeholder="Apelido" class="form-control" type="text">                         </div>                     </div>                 </div>                  <div class="form-group">                     <label class="col-md-4 control-label"></label>                     <div class="col-md-4 inputGroupContainer">                         <div class="input-group">                             <span class="input-group-addon"><i class="glyphicon glyphicon-camera"></i></span>                             <!--<input name="foto" type="file" >-->                             <!-- <form method="post" enctype="multipart/form-data"> -->                             <input type="file" name="files[]" multiple>                             <!-- <input type="submit" value="Upload File" name="submit">                             </form> -->                         </div>                     </div>                 </div>                  <div class="form-group">                     <label class="col-md-4 control-label"></label>                     <div class="col-md-4 inputGroupContainer">                         <div class="input-group">                             <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>                             <input name="nome" placeholder="Nome completo" class="form-control" type="text">                         </div>                     </div>                 </div>                  <div class="form-group">                     <label class="col-md-4 control-label"></label>                     <div class="col-md-4 inputGroupContainer">                         <div class="input-group">                             <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>                             <input name="email" placeholder="E-Mail" class="form-control" type="text">                         </div>                     </div>                 </div>                  <div class="form-group">                     <label class="col-md-4 control-label"></label>                     <div class="col-md-4 inputGroupContainer">                         <div class="input-group">                             <span class="input-group-addon"><i class="glyphicon glyphicon-barcode"></i></span>                             <input name="cpf" placeholder="CPF" class="form-control" type="text" maxlength="14" onkeypress="formatar('###.###.###-##', this);">                         </div>                     </div>                 </div>                  <div class="form-group">                     <label class="col-md-4 control-label"></label>                     <div class="col-md-4 inputGroupContainer">                         <div class="input-group">                             <span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>                             <input name="cidade" placeholder="Cidade e estado (Ex: Salvador/BA)" class="form-control" type="text">                         </div>                     </div>                 </div>                   <div class="form-group">                     <label class="col-md-4 control-label"></label>                     <div class="col-md-4 inputGroupContainer">                         <div class="input-group">                             <span class="input-group-addon"><i class="glyphicon glyphicon-eye-open"></i></span>                             <input name="insta" placeholder="ID do Instagram (Sem o @)" class="form-control" type="text">                         </div>                     </div>                 </div>                   <div class="form-group">                     <label class="col-md-4 control-label"></label>                     <div class="col-md-4">                         <input type="submit" value="Finalizar Inscrição" name="submit" class="btn btn-default col-md-12">                          <!-- <button type="submit" name="submit" class="btn btn-default col-md-12">Finalizar Inscrição :)</button> -->                     </div>                 </div>             </fieldset>         </form>     </div>     <script src="upload.js"></script>     <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>     <script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'></script>     <script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-validator/0.4.5/js/bootstrapvalidator.min.js'></script>      <!-- ****** Simples função de colocar mascara em javascript ****** -->     <script>         function formatar(mascara, documento) {             var i = documento.value.length;             var saida = mascara.substring(0, 1);             var texto = mascara.substring(i);             if (texto.substring(0, 1) != saida) {                 documento.value += texto.substring(0, 1);             }         }      </script>      <!-- ****** Validando o formulário (inclusive o CPF) ****** -->     <script>         $  (document).ready(function() {             $  ('#contact_form').bootstrapValidator({                 feedbackIcons: {                     valid: 'glyphicon glyphicon-ok',                     invalid: 'glyphicon glyphicon-remove',                     validating: 'glyphicon glyphicon-refresh'                 },                 fields: {                     apelido: {                         validators: {                             stringLength: {                                 min: 2,                             },                             notEmpty: {                                 message: 'Insira o seu apelido'                             }                         }                     },                     nome: {                         validators: {                             stringLength: {                                 min: 2,                             },                             notEmpty: {                                 message: 'Insira o seu nome'                             }                         }                     },                     cidade: {                         validators: {                             stringLength: {                                 min: 2,                             },                             notEmpty: {                                 message: 'Insira a sua cidade e estado (Ex: Salvador/BA)'                             }                         }                     },                     insta: {                         validators: {                             stringLength: {                                 min: 2,                             },                             notEmpty: {                                 message: 'Insira o ID do instagram (sem o @)'                             }                         }                     },                     email: {                         validators: {                             notEmpty: {                                 message: 'Insira o seu e-mail'                             },                             emailAddress: {                                 message: 'E-mail incorreto'                             }                         }                     },                     cpf: {                         validators: {                             callback: {                                 message: 'CPF Invalido',                                 callback: function(value) {                                     //retira mascara e nao numeros                                            cpf = value.replace(/[^\d]+/g, '');                                     if (cpf == '') return false;                                      if (cpf.length != 11) return false;                                      // testa se os 11 digitos são iguais, que não pode.                                     var valido = 0;                                     for (i = 1; i < 11; i++) {                                         if (cpf.charAt(0) != cpf.charAt(i)) valido = 1;                                     }                                     if (valido == 0) return false;                                      //  calculo primeira parte                                       aux = 0;                                     for (i = 0; i < 9; i++)                                         aux += parseInt(cpf.charAt(i)) * (10 - i);                                     check = 11 - (aux % 11);                                     if (check == 10 || check == 11)                                         check = 0;                                     if (check != parseInt(cpf.charAt(9)))                                         return false;                                      //calculo segunda parte                                       aux = 0;                                     for (i = 0; i < 10; i++)                                         aux += parseInt(cpf.charAt(i)) * (11 - i);                                     check = 11 - (aux % 11);                                     if (check == 10 || check == 11)                                         check = 0;                                     if (check != parseInt(cpf.charAt(10)))                                         return false;                                     return true;                                   }                             }                         }                     }                 }             })          });      </script>  </body>  </html> 

process.php

<?php   if ($  _SERVER['REQUEST_METHOD'] === 'POST') {     if (isset($  _FILES['files'])) {         $  errors = [];         $  path = 'inscrito/fotos/';     $  extensions = ['jpg', 'jpeg', 'png', 'gif'];          $  all_files = count($  _FILES['files']['tmp_name']);          for ($  i = 0; $  i < $  all_files; $  i++) {           $  file_name = $  _FILES['files']['name'][$  i];         $  file_tmp = $  _FILES['files']['tmp_name'][$  i];         $  file_type = $  _FILES['files']['type'][$  i];         $  file_size = $  _FILES['files']['size'][$  i];         $  file_ext = strtolower(end(explode('.', $  _FILES['files']['name'][$  i])));          $  file = $  path . $  file_name;          if (!in_array($  file_ext, $  extensions)) {             $  errors[] = 'Extension not allowed: ' . $  file_name . ' ' . $  file_type;         }          if ($  file_size > 2097152) {             $  errors[] = 'File size exceeds limit: ' . $  file_name . ' ' . $  file_type;         }          if (empty($  errors)) {             move_uploaded_file($  file_tmp, $  file);         }     }      if ($  errors) print_r($  errors);     } } 

upload.js

const url = 'process.php'; const form = document.querySelector('form');  form.addEventListener('submit', e => {     e.preventDefault();      const files = document.querySelector('[type=file]').files;     const formData = new FormData();      for (let i = 0; i < files.length; i++) {         let file = files[i];          formData.append('files[]', file);     }      fetch(url, {         method: 'POST',         body: formData     }).then(response => {         console.log(response);     }); }); 

gerador.php

<?php setlocale( LC_ALL, 'pt_BR', 'pt_BR.iso-8859-1', 'pt_BR.utf-8', 'portuguese' ); date_default_timezone_set( 'America/Sao_Paulo' ); require('fpdf/alphapdf.php'); require('PHPMailer/class.phpmailer.php');   // --------- Variáveis do Formulário ----- // $  apelido     = $  _POST['apelido']; $  nome     = $  _POST['nome']; $  files     = $  _POST['files']; $  email    = $  _POST['email']; $  cpf      = $  _POST['cpf']; $  cidade   = $  _POST['cidade']; $  insta    = $  _POST['insta'];  // --------- Variáveis que podem vir de um banco de dados por exemplo ----- // //$  empresa  = "Universidade do Lincoln Borges"; //$  curso    = "Workshop Segurança da Informação"; //$  data     = "29/05/2017"; //$  carga_h  = "8 horas";   //$  texto1 = utf8_decode($  empresa); //$  texto2 = utf8_decode("pela participação no ".$  curso." \n realizado em ".$  data." com carga horária total de ".$  carga_h."."); //$  texto3 = utf8_decode("São Paulo, ".utf8_encode(strftime( '%d de %B de %Y', strtotime( date( 'Y-m-d' ) ) )));   $  pdf = new AlphaPDF();  // Orientação Landing Page /// $  pdf->AddPage('L');  $  pdf->SetLineWidth(1.5);   // desenha a imagem do certificado $  pdf->Image('certificado.jpg',0,0,295);  // opacidade total $  pdf->SetAlpha(1);  // Mostrar texto no topo $  pdf->SetFont('Arial', '', 15); // Tipo de fonte e tamanho $  pdf->SetXY(109,46); //Parte chata onde tem que ficar ajustando a posição X e Y $  pdf->MultiCell(265, 10, $  texto1, '', 'L', 0); // Tamanho width e height e posição  // Mostrar o nome $  pdf->SetFont('Arial', '', 30); // Tipo de fonte e tamanho $  pdf->SetXY(20,86); //Parte chata onde tem que ficar ajustando a posição X e Y $  pdf->MultiCell(265, 10, $  nome, '', 'C', 0); // Tamanho width e height e posição  // Mostrar o corpo $  pdf->SetFont('Arial', '', 15); // Tipo de fonte e tamanho $  pdf->SetXY(20,110); //Parte chata onde tem que ficar ajustando a posição X e Y $  pdf->MultiCell(265, 10, $  texto2, '', 'C', 0); // Tamanho width e height e posição  // Mostrar a data no final $  pdf->SetFont('Arial', '', 15); // Tipo de fonte e tamanho $  pdf->SetXY(32,172); //Parte chata onde tem que ficar ajustando a posição X e Y $  pdf->MultiCell(165, 10, $  texto3, '', 'L', 0); // Tamanho width e height e posição  $  pdfdoc = $  pdf->Output('', 'S');    // ******** Agora vai enviar o e-mail pro usuário contendo o anexo // ******** e também mostrar na tela para caso o e-mail não chegar  $  subject = utf8_decode('Inscrição concluída com sucesso !'); $  messageBody = "Confirmando dados<br><br> $  apelido <br> $  nome <br> $  email <br> $  cpf <br> $  cidade <br> $  insta <br> $  foto   "; //$  messageBody = "Olá $  apelido //<br><br> //Sua inscrição feita em nome de <b>$  nome</b>, portador do CPF <b>$  cpf</b>, foi efetuada com sucesso ! //<br><br> //Agora basta que você responda este e-mail anexando o seu comprovante de depósito/transferência para: //<br><br> //<b>Banco Santander</b><br>  // //";   $  mail = new PHPMailer(); $  mail->SetFrom("oi@xxx.xxx", "Evento"); $  mail->Subject    = $  subject; $  mail->MsgHTML(utf8_decode($  messageBody));   $  mail->AddAddress($  email);  //$  mail->addStringAttachment($  pdfdoc, 'certificado.pdf'); $  mail->Send();  $  certificado="arquivos/$  nome.pdf"; //atribui a variável $  certificado com o caminho e o nome do arquivo que será salvo (vai usar o CPF digitado pelo usuário como nome de arquivo) $  pdf->Output($  certificado,'F'); //Salva o certificado no servidor (verifique se a pasta "arquivos" tem a permissão necessária) // Utilizando esse script provavelmente o certificado ficara salvo em www.seusite.com.br/inscrito/arquivos/999.999.999-99.pdf (o 999 representa o CPF digitado pelo usuário) //$  pdf->Output(); // Mostrar o certificado na tela do navegador   //Gerador de QR Code para perfil do instagram //<img src="https://chart.googleapis.com/chart?cht=qr&amp;chl=instagram%3A%2F%2Fuser%3Fusername%3D'.$  insta.'&amp;chld=L|0&amp;chs=300" border="0">   ?> 

Angular 7 – Nav Child component display router-outlet vs iframe

I have created a Angular 7 web app data-driven display of navigation items and content to be shown when a nav item is selected.

I have the following nav item interface:

interface NavItem {   title: string;   icon: string;   link: string;   pages?: NavItem[]; } 

Where it can be implemented like so for an Angular route:

title: 'Home', icon: 'faCoffee', // from Material CSS link: '/home', // Notice it is an Angular route pages: null 

Or like this:

title: 'Company Name', icon: 'faCompany', link: 'http://subdomain.company.com', // Notice it is an external URI pages: null 

I have the following in nav.component.html:

<div *ngFor="let navItem of navItems">       <!-- use a simple div for an item that has no children,         match up the styling to the expansion panel styles -->       <div class="nav-head" *ngIf="navItem.pages === null">         <a class="nav-link"           (click)="changeLink(navItem.link)" // (1)           routerLinkActive="selected">           <mat-icon>{{navItem.icon}}</mat-icon>           <span class="nav-link-text">{{navItem.title}}</span>         </a>       </div>     </div>  <app-content-display [hyperlink]="rawLink"></app-content-display> // (2) 

In nav.component.ts

export class NavComponent {   rawLink: string = "/";    public navList: NavItem[];    changeLink(link: string){ // (1)     this.rawLink = link;   } } 

app-content-display directive is defined like so:

content-display.component.ts:

@Component({   selector: 'app-content-display', // (2)   templateUrl: './content-display.component.html',   styleUrls: ['./content-display.component.scss'] }) export class ContentDisplayComponent implements OnInit {    private _link = '';   isAngularLink = true;    @Input()   set hyperlink(hyperlink: string){ // When a setter is triggered by (1), the value is checked to determine if it is an Angular route. The output then decides whether to show an angular router-outlet or to show an iframe.     this._link = hyperlink;     this.isAngularLink = this.checkIfAngularLink();      if(this.isAngularLink){       this.router.navigate([`$  {this._link}`]);     }   }    get hyperlink(): string{     return this._link;   }    trustedLink = () => {     return this.sanitizer.bypassSecurityTrustResourceUrl(this.hyperlink); // Has to be a function as opposed to a property that gets   }     constructor(private sanitizer: DomSanitizer, private router: Router ) {  }    ngOnInit() {}    checkIfAngularLink(){      if(this._link.indexOf('company.com') > 0){       return false;     }      return true;   } } 

On content-display.component.html:

<div *ngIf="isAngularLink">   <router-outlet></router-outlet> </div>  <div *ngIf="!isAngularLink">   <iframe [src]="trustedLink()" width="100%" height="800px"></iframe> </div> 

The end result is:

The parent component (nav.component) shows a child component (content-display.component). When a link is clicked on parent component, the child component’s hyperlink property receives the link, checks if it is an Angular route vs external resources.

  1. If a user clicks on a navigation link that points to an internal Angular page, router-outlet will show the output
  2. If a user clicks on a navigation link that points to an external URI, an iframe will be called to show the output.

I feel that child component (content-display.component) may know and do too much and may need refactoring. However, I don’t anticipate child component will be reused by other areas of the web app.

Unknown Apple TV showing up in system audio menu

When opening the volume control / audio menu in the system menu bar I sometimes see “Apple TV” among the possible audio sinks. I don’t own an Apple TV nor does one exist on my network so I’m assuming it’s detecting a neighbor’s device using Bluetooth. I’ve selected it twice accidentally while typing this.

The device also shows up in the display selection menu. I guess it will ask me for a verification code if I select it, but it’s kind of uncomfortable to feel like I could start broadcasting my screen at any time by mistake (even if it isn’t possible).

Is it possible to make macOS (10.14.3) stop displaying devices I don’t own and aren’t paired with?

When Grappling multiple creatures, how many Grapples do you roll?

Various abilities allow creatures to Grapple with more than one other creature. Some examples:

  • Mimics grapple with everyone that they hit with a Slam attack, automatically, unless they dissolve their Adhesive (Ex)
  • Creatures with the Grab ability can take -20 to not have the Grappled condition and potentially Grab other creature(s), even before their next turn
  • A creature Grappling with another might be Grappled by a 3rd and attempt to reverse that Grapple

When attempting to maintain (or reverse) a Grapple, are you able to roll for all Grappled creatures at once? Each Grappled creature as one action? Or are you only able to Grapple one (two/three if you have Greater and/or Rapid Grappler) and have to drop the others?

QA a Chat Bot Relating to UX/CX [closed]

I’ve been tasked with checking over a chat bot from a UX/CX perspective. This is the first time I’ve looked a chat bot from this point of view. What can I do a heuristic analysis and UX baseline metrics for?

Eg response time, CSAT, declare it’s a bot, reduction in phone calls or emails

It’s AI and ML capabilities are in the early learning stages so it’s still scripted conversation.

Review My Technical SEO Specialist Resume

Please review my interactive SEO resume that created to provide a working example of what I do along with SEO Examples and SEO Clients.

View My Resume Now: Resume for Brett Topovski – Technical SEO Specialist

My interactive resume includes detailed examples of keywords that I've help improve the performance of with my technical SEO services over the past few years. My resume also include copywriting examples and articles that…

Review My Technical SEO Specialist Resume

IF OR Syntax in SharePoint

I need help adding some logic to my syntax…current formula is set to the following value and it works perfectly:

=IF(AAA<>””,”Closed”,IF([BBB]<>””,”Pending Approval”,”Pending Review”))

I’d like to add some OR logic to this part ([BBB]<>””OR”ZZZ”, and essentially want the formula to perform this:

=IF(AAA<>””,”Closed”,IF([BBB]<>””OR”ZZZ”,”Pending Approval”,”Pending Review”))

this doesn’t work either:

=IF(AAA<>””,”Closed”,IF(OR(ISBLANK([BBB]),”Pending Approval”),”Pending Review”),(OR([BBB])<>”ZZZ”,”Pending Approval”,”Pending Review”)

Can anyone help with this?